我在扩展 spree 控制器时遇到问题。当我覆盖控制器时,我无法访问 Order 类。我收到以下错误(我使用spree 1.2.4):
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
我应该怎么做才能访问 Order 类?