未定义的方法`mount_uploader'为类别:类Mongoid Nginx Passenger

我在我的应用程序中使用carrierwave。 问题是它在开发模式下运行良好。 但是当与乘客一起部署到nginx时会抛出以下错误:

/home/webserver/raw/releases/20110919033346/app/models/category.rb:11: undefined method `mount_uploader' for Category:Class (NoMethodError) from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:454:in `load' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:454:in `load_file' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:453:in `load_file' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:340:in `require_or_load' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:300:in `depend_on' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:216:in `require_dependency' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/rails/mongoid.rb:55:in `load_model' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/rails/mongoid.rb:18:in `load_models' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/rails/mongoid.rb:17:in `each' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/rails/mongoid.rb:17:in `load_models' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/paths.rb:102:in `each' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/paths.rb:102:in `each' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/rails/mongoid.rb:16:in `load_models' from /opt/ruby/lib/ruby/gems/1.8/gems/mongoid-2.0.1/lib/mongoid/railtie.rb:88:in `_callback_before_5' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:420:in `_run_prepare_callbacks' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/callbacks.rb:40:in `initialize' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:33:in `new' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:33:in `build' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `build' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:209:in `inject' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `each' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `inject' from /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action_dispatch/middleware/stack.rb:79:in `build' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:162:in `build_middleware_stack' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application/finisher.rb:35 from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `run_initializers' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `send' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing' from /home/webserver/raw/releases/20110919033346/config/environment.rb:5 from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency' from /opt/ruby/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/application.rb:103:in `require_environment!' from /opt/ruby/lib/ruby/gems/1.8/gems/railties-3.0.9/lib/rails/commands.rb:22 from script/rails:6:in `require' from script/rails:6 

这是我的gem名单

 abstract (1.0.0) actionmailer (3.0.9, 3.0.7) actionpack (3.0.9, 3.0.7) activemodel (3.0.9, 3.0.7) activerecord (3.0.9, 3.0.7) activeresource (3.0.9, 3.0.7) activesupport (3.1.0, 3.0.9, 3.0.7) akami (1.0.0) arel (2.0.10) bcrypt-ruby (3.0.0) bson (1.3.1) bson_ext (1.3.1) builder (3.0.0, 2.1.2) bundle (0.0.1) bundler (1.0.13) carrierwave (0.5.7, 0.5.6, 0.5.4) daemon_controller (0.2.6) erubis (2.6.6) escape (0.0.4) exception_notification_rails3 (1.2.0) fastthread (1.0.7) gyoku (0.4.4) httpi (0.9.5, 0.9.4) i18n (0.6.0, 0.5.0) mail (2.2.19) mime-types (1.16) mini_magick (3.3, 3.2.1) mongo (1.3.1) mongoid (2.0.1) multi_json (1.0.3) nokogiri (1.5.0, 1.4.4) nori (1.0.2, 0.2.2) passenger (3.0.7) polyglot (0.3.2, 0.3.1) pr_geohash (1.0.0) pyu-ntlm-http (0.1.3.1) rack (1.2.3) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.9, 3.0.7) railties (3.0.9, 3.0.7) rake (0.9.2, 0.9.0) rdoc (3.9.4, 3.8) rmagick (2.13.1) rsolr (0.12.1) rubyzip (0.9.4) savon (0.9.7, 0.9.6, 0.9.2) subexec (0.1.0, 0.0.4) sunspot (1.2.1) sunspot_rails_mongoid (1.2.1) SystemTimer (1.2.3) thor (0.14.6) treetop (1.4.10, 1.4.9) tzinfo (0.3.29, 0.3.27) wasabi (2.0.0) will_paginate (3.0.0, 3.0.pre4, 3.0.pre2) 

ruby的版本是ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.02

请,可以给任何想法。 先谢谢你!

    我有类似的问题。 就我而言,这是愚蠢的。 在我的Gemfile中,我只是引用了gem,但是你需要需要mongoid扩展。 所以你在Gemfile中的行应该是这样的:

     gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'