狂欢多货币

时间:2014-01-28 10:35:26

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

我在我的狂欢应用程序中使用spree_multi_currency gem https://github.com/pronix/spree-multi-currency。它工作,但当我将产品添加到购物车时,它会给出错误,如

undefined method `target_shipment=' for #<Spree::Variant:0xb4ea7b80>

def add_to_line_item(line_item, variant, quantity, currency = nil, shipment = nil)
 if line_item
  line_item.target_shipment = shipment
  line_item.quantity += quantity.to_i
  line_item.currency = currency unless currency.nil?
 else
  .......
end

这是我的全部追踪

activemodel (4.0.2) lib/active_model/attribute_methods.rb:439:in `method_missing'
activerecord (4.0.2) lib/active_record/attribute_methods.rb:155:in `method_missing'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-multi-currency-0abaa72ab8ed/app/models/spree/order_decorator.rb:7:in `add_to_line_item'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/core/app/models/spree/order_contents.rb:10:in `add'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/core/app/models/spree/order_populator.rb:49:in `attempt_cart_add'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/core/app/models/spree/order_populator.rb:26:in `block in populate'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/core/app/models/spree/order_populator.rb:25:in `each'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/core/app/models/spree/order_populator.rb:25:in `populate'
/home/tps/.rvm/gems/ruby-2.0.0-p247/bundler/gems/spree-99a6ad9f0e4e/frontend/app/controllers/spree/orders_controller.rb:44:in `populate'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action'

提前致谢。

1 个答案:

答案 0 :(得分:1)

看起来你正在使用的Spree提交中定义的方法与spree_multi_currency中的方法之间存在不匹配。

狂欢: add_to_line_item(variant, quantity, currency, shipment)

Spree_multi_currency: add_to_line_item(line_item, variant, quantity, currency = nil, shipment = nil)

确保您使用扩展程序的正确分支来匹配您的Spree分支。