我想在我的spree扩展中添加新的javascript文件

时间:2015-06-04 20:54:48

标签: ruby-on-rails ruby spree braintree braintree-rails

我是铁杆新手。我正在尝试构建Spree扩展以使用Braintree的插入式UI。我正在尝试将新的braintree.js添加到我的扩展程序中。这些是我到目前为止所做的步骤。

  1. tenant2.users添加到braintree.js

  2. <my_extension>/app/assets/javascripts/spree/frontend/添加到//= require spree/frontend/braintree

  3. app/assets/javascripts/spree/frontend/<my_extension>.js中创建braintree.rb。该文件的内容:

    <my_extension>/config/initializers/
  4. 在我的狂欢商店里,我跑了Braintree::Configuration.environment = :sandbox Braintree::Configuration.merchant_id = "merchant_id" Braintree::Configuration.public_key = "public_key" Braintree::Configuration.private_key = "private_key" ,这是成功的。

  5. Ran bundle install给出了以下错误:

    rails g <my_extension>:install

1 个答案:

答案 0 :(得分:0)

您需要将gemspec中的braintree gem作为依赖项,然后需要lib / spree_hello_ext.rb才能在初始化程序尝试使用它之前对其进行初始化。类似于spree_gateway所需的spree_core: https://github.com/spree/spree_gateway/blob/master/lib/spree_gateway.rb#L1