2014-01-28 132 views
2

我在我的大禮包中使用spree_multi_currency gem https://github.com/pronix/spree-multi-currency。它工作,但是當我添加產品到購物車當時它給錯誤,如Spree多種貨幣

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' 

在此先感謝。

+0

你可以添加一個完整的堆棧跟蹤?不確定target_shipment來自哪裏,能夠幫助您解答問題。 – GeekOnCoffee

+0

@GeekOnCoffee我添加了完整的跟蹤。 –

+0

這個網站是公開的嗎?我們一直在尋找瘋狂的多貨幣示例。 – GeekOnCoffee

回答

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)

確保您使用擴展的正確的分支,以配合您的狂歡分支。

+0

感謝您的幫助。再次感謝您的指導,我解決了我的問題。 –