How to access Rails Engines methods from main application?

前端 未结 1 1985
夕颜
夕颜 2021-01-20 18:56

I\'m trying to use the current_order method defined in the Spree::Core engine: https://github.com/spree/spree/blob/master/core/lib/spree/core/current_order.rb

In my

1条回答
  •  鱼传尺愫
    2021-01-20 19:43

    This question is a bit old, but here is a possible answer, for the record.

    Maybe you can work around by using a piece of the spree code in your controller. It's generally a better idea to have the code in the controller (or, in the case of Spree, in a controller_decorator), than in the view.

    For example if you need this in your products view as @current_order:

    Spree::ProductsController.class_eval do
      @current_order = Spree::Order.find(session[:order_id])
    end
    

    But I don't know why it's working in development and not in production.

    0 讨论(0)
提交回复
热议问题