How to access Rails Engines methods from main application?

喜欢而已 提交于 2019-12-01 22:39:03

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!