0
我在擴展一個熱潮控制器時遇到了問題。當我重寫控制器時,我無法訪問Order類。我得到以下錯誤(我用大禮包1.2.4):Spree - 訪問訂單類
NameError (uninitialized constant Spree::Admin::OrdersController::Order):
spree_russian_post/app/controllers/admin/orders_controller_decorator.rb:9:in `sample_method'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
...
的問題是在我的控制器:
spree_russian_post/app/controllers/admi /orders_controller_decorator.rb
這裏是代碼:
require 'spree_core'
Spree::Admin::OrdersController.class_eval do
def sample_method
@order = Order.find_by_param(params[:id]) #Here I get the error
....
end
end
我應該怎麼做才能訪問訂單類?