rails中的范围分辨率错误

时间:2014-06-13 08:28:33

标签: ruby-on-rails scope

module Spree
  module Admin
    class Spree::Admin::DefaultRedemptionBooksController < Spree::Admin::BaseController
      before_filter :authorize_admin

      def index
        @default_redemption_books = DefaultRedemptionBook.order('year desc, month')
        respond_to do |format|
          format.html
          format.csv { render text: @default_redemption_books.to_csv }
        end
      end
end
end

当我跑步时,它给了我们

NameError (uninitialized constant Spree::DefaultRedemptionBook):
activesupport (3.2.13) lib/active_support/inflector/methods.rb:230:in `block in constantize'
activesupport (3.2.13) lib/active_support/inflector/methods.rb:229:in `each'
activesupport (3.2.13) lib/active_support/inflector/methods.rb:229:in `constantize'
activesupport (3.2.13) lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/mnt/processing_dir/librify/librify-apps/shared/bundle/ruby/1.9.1/bundler/gems/spree_auth_devise-a6ae3646234d/app/controllers/spree/admin/admin_controller_decorator.rb:8:in `model_class'
/mnt/processing_dir/librify/librify-apps/shared/bundle/ruby/1.9.1/gems/spree_backend-2.0.3/app/controllers/spree/admin/base_controller.rb:19:in `authorize_admin'
activesupport (3.2.13) lib/active_support/callbacks.rb:506:in `_run__2536621662702313430__process_action__1018742768700982955__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal

我 已经DefaultRedemptionBook但它试图在狂欢中找到请帮助我

1 个答案:

答案 0 :(得分:0)

我的问题解决了

Renamedd DefaultRedemptionBooksController并且它的工作正常,因为我有两个同名的类,所以它混淆了,控制器调用另一个文件