我下面http://railscasts.com/episodes/145-integrating-active-merchant爲active_merchant配置設置,以兼容一個Rails 3應用程序
如何設置的配置設置爲與一個Rails 3應用程序兼容。
我試圖把下面的config/initializers/active_merchant.rb
if Rails.env == 'development'
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(
:login => 'seller12341234zxcv.foobar.com',
:password => 'pasword',
:signature => 'abc123'
)
end
elsif Rails.env == 'test'
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::BogusGateway.new
end
elsif Rails.env == 'production'
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(
:login => 'seller12341234zxcv.foobar.com',
:password => 'pasword',
:signature => 'abc123'
)
end
end
下生成一個錯誤:
config/initializers/active_merchant.rb:2:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
在'配置/環境中添加該代碼/ .rb'文件是一個軌道2的事情,並不完全兼容軌道3.因爲這個原因升級軌道2.3應用程序時遇到問題。 Rails 3的方法是將所有這些配置放入初始化文件中。 –