未初始化的常量 ActiveMerchant::Billing::CreditCard::Validateable (NameError) - 在 Spree 商店
Posted
技术标签:
【中文标题】未初始化的常量 ActiveMerchant::Billing::CreditCard::Validateable (NameError) - 在 Spree 商店【英文标题】:uninitialized constant ActiveMerchant::Billing::CreditCard::Validateable (NameError) - in Spree shop 【发布时间】:2015-08-22 07:14:21 【问题描述】:我是 Rails 新手。今天我尝试将我的商店(SpreeShop)部署到新的生产服务器,但是有些错误。我对一些 gem 有一个愚蠢的问题:activemerchant (1.34.1)。
下面是我的堆栈跟踪。
uninitialized constant ActiveMerchant::Billing::CreditCard::Validateable (NameError)
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant/billing/credit_card.rb:51:in `<class:CreditCard>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant/billing/credit_card.rb:49:in `<module:Billing>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant/billing/credit_card.rb:6:in `<module:ActiveMerchant>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant/billing/credit_card.rb:5:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant/billing.rb:5:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/activemerchant-1.34.1/lib/active_merchant.rb:56:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/bundler/gems/spree-3a3652adb1e8/core/lib/spree/core.rb:8:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/bundler/gems/spree-3a3652adb1e8/core/lib/spree_core.rb:1:in `require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/bundler/gems/spree-3a3652adb1e8/core/lib/spree_core.rb:1:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/bundler/gems/spree-3a3652adb1e8/lib/spree.rb:1:in `require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/bundler/gems/spree-3a3652adb1e8/lib/spree.rb:1:in `<top (required)>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/home/dp/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/home/dp/dp/releases/20150607162220/config/application.rb:7:in `<top (required)>'
/home/dp/dp/releases/20150607162220/config/environment.rb:2:in `require'
/home/dp/dp/releases/20150607162220/config/environment.rb:2:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@quiselle/gems/passenger-4.0.26/helper-scripts/rack-preloader.rb:105:in `eval'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/passenger-4.0.26/helper-scripts/rack-preloader.rb:105:in `preload_app'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/passenger-4.0.26/helper-scripts/rack-preloader.rb:150:in `<module:App>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/passenger-4.0.26/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/home/dp/.rvm/gems/ruby-1.9.3-p429@dp/gems/passenger-4.0.26/helper-scripts/rack-preloader.rb:28:in `<main>'
你知道如何解决这个问题吗???我读过另一篇有类似问题的帖子,但没有任何帮助....
【问题讨论】:
【参考方案1】:未初始化的常量 ActiveMerchant::Billing::CreditCard::Validateable 问题与 active_utils
gem 的版本有关。版本 3 抛出错误;版本 2 没有。您需要在 Gemfile 中设置 gem 版本。
# Gemfile
gem 'active_utils', '2.0.2'
gem 'activemerchant', '~> 1.32.1', require: 'active_merchant'
【讨论】:
【参考方案2】:这与https://github.com/Shopify/active_utils/issues/57 中详述的问题相同。
该问题的修复已包含在 active_merchant gem on Jan 15th, 2015 中,并且在 activemerchant 版本 1.47.0
或更高版本中可用。
因此,要解决您的 Rails 应用程序上的问题,请更新 activemerchant gem 版本。步骤如下:
-
修改
Gemfile
并将active_merchant gem版本设置为gem 'activemerchant', '1.50.0'
运行bundle install
任何高于1.47.0
的activemerchant gem 版本都可以使用。
更新
active_merchant-payu gem 不依赖于activemerchant
的任何特定版本。运行bundle update
强制它使用最新版本的activemerchant
gem。
【讨论】:
好的,但我正在使用来自:github.com/estrai/active_merchant-payu 的 gem,你觉得我的 gem 有什么问题?以上是关于未初始化的常量 ActiveMerchant::Billing::CreditCard::Validateable (NameError) - 在 Spree 商店的主要内容,如果未能解决你的问题,请参考以下文章