我是新来的。我正在尝试构建 Spree 扩展以使用 Braintree 的插入式 UI。我正在尝试将新的 Braintree.js 添加到我的扩展程序中。这些是我到目前为止所做的步骤。
添加
braintree.js
到<my_extension>/app/assets/javascripts/spree/frontend/
添加
//= require spree/frontend/braintree
到app/assets/javascripts/spree/frontend/<my_extension>.js
.创建
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"
从我的狂欢商店我跑了
bundle install
,这是成功的。Ran
rails 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)