0

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

  1. 添加braintree.js<my_extension>/app/assets/javascripts/spree/frontend/

  2. 添加//= require spree/frontend/braintreeapp/assets/javascripts/spree/frontend/<my_extension>.js.

  3. 创建braintree.rb<my_extension>/config/initializers/. 该文件的内容:

    Braintree::Configuration.environment = :sandbox
    Braintree::Configuration.merchant_id = "merchant_id"
    Braintree::Configuration.public_key = "public_key"
    Braintree::Configuration.private_key = "private_key"
    
  4. 从我的狂欢商店我跑了bundle install,这是成功的。

  5. Ranrails g <my_extension>:install这给了我以下错误:

    append  vendor/assets/javascripts/spree/frontend/all.js
    append  vendor/assets/javascripts/spree/backend/all.js
    insert  vendor/assets/stylesheets/spree/frontend/all.css
    insert  vendor/assets/stylesheets/spree/backend/all.css
    run  bundle exec rake railties:install:migrations FROM=spree_hello_ext 
    
    from "."
    Would you like to run the migrations now? [Y/n] y
    run  bundle exec rake db:migrate from "."
    rake aborted!
    NameError: uninitialized constant Braintree
    /Users/<user>/Sites/spree_hello_ext/config/initializers/braintree.rb:1:in 
       `<top (required)>'
    /Users/<user>/Sites/hellostore/config/environment.rb:5:in `<top (required)>'
    Tasks: TOP => db:migrate => environment
    (See full trace by running task with --trace)
    
4

1 回答 1

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

于 2015-06-09T13:57:05.110 回答