English 中文(简体)
铁路上的红宝石 + heroko + mongoid + 设计 = 未初始化的常数用户 (NameError)
原标题:ruby on rails + heroku + mongoid + devise = uninitialized constant User (NameError)

将应用程序安装到 Heroko 时, 我发现一个错误。 在寻找解决方案的3天后, 它像常见错误一样缝合, 但我还没有找到解决方案 。 我的应用程序正在运行的计算机上运行完好地运行 :

  • Mac OSX 10.7.3 with ruby
  • ruby ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin11.3.0]
  • rubygem 1.3.7.1 (also tested with 1.8.24)

My Heroky App在雪松堆上, 配有卡通:MongoHQ MOngoHQ Free, 共享数据库5MB。

  • heroku run gem --version gives: 1.3.7
  • heroku run ruby --version gives: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

将程序推到Heroky时我犯的错误是:

lib/active_support/inflector/methods.rb:229:in `block in constantize : uninitialized constant User (NameError)

更多信息: 我使用mongohq 的mongoid 设计。 我相信这来自设计, 因为我在用户模型上使用它。 请注意, 我的 ap/ models/ User. rb 文件被执行, 应用程序中的用户和用户之间没有打字。 我不需要我的配置/ 应用程序. rb 文件中的“ 激活_ record/ railtie ” 。 因此, 我的用户模型没有扩展 AmericalRecord: Base, 但是这必须是完全正常的 。

我真的希望有人能帮助我, 因为我在这个问题上坚持太久了,

这里是我的应用程序 Gemfile :

source "http://rubygems.org"

gem "rails", "3.2.3"

gem "bundler"

gem "rake", "0.9.2.2"

group :production do
  gem "thin", "~> 1.3"
end

# DATABASE
gem "mongo",    "~> 1.6"
gem "bson_ext", "~> 1.6"
gem "mongoid",  "~> 2.4"
gem "mongoid_token", "~> 1.0"

# FORMS
gem "dynamic_form", "~> 1.1"

# FILE UPLOAD
gem "mini_magick", "~> 3.4"
gem "carrierwave", "~> 0.6"
gem "carrierwave-mongoid", :require => "carrierwave/mongoid"

# ASSETS
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem "sass-rails",   "~> 3.2"
  gem "coffee-rails", "~> 3.2"
  gem "uglifier",     "~> 1.2"
end

# JAVASCRIPT
gem "jquery-rails", "~> 2.0"

# PAGINATION
gem "kaminari", "~> 0.13"

# AUTHORISATION
gem "devise", "~> 2.1"
gem "cancan", "~> 1.6"

这里是赫鲁库的日志:

2012-05-25T18:24:23+00:00 heroku[web.1]: State changed from created to starting
2012-05-25T18:24:25+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e production -p 33048`
2012-05-25T18:24:30+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-05-25T18:24:30+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2012-05-25T18:24:32+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:229:in `block in constantize : uninitialized constant User (NameError)
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `each 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/inflector/methods.rb:228:in `constantize 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise.rb:252:in `get 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/mapping.rb:77:in `to 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/mapping.rb:72:in `modules 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/mapping.rb:89:in `routes 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/mapping.rb:66:in `initialize 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/mapping.rb:156:in `default_used_route 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise.rb:286:in `new 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/rails/routes.rb:207:in `block in devise_for 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/rails/routes.rb:206:in `each 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise.rb:286:in `add_mapping 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/rails/routes.rb:206:in `devise_for 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/config/routes.rb:3:in `block in <top (required)> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `eval_block 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/config/routes.rb:1:in `<top (required)> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:in `draw 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `block in load_paths 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `each 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `load_paths 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in `reload! 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.0/lib/devise/rails.rb:14:in `block in <class:Engine> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:108:in `reload_routes! 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:34:in `call 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:42:in `each 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application/finisher.rb:52:in `block in <module:Finisher> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize! 
2012-05-25T18:24:32+00:00 app[web.1]:   from config.ru:3:in `require 
2012-05-25T18:24:32+00:00 app[web.1]:   from config.ru:3:in `block in <main> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/config/environment.rb:5:in `<top (required)> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval 
2012-05-25T18:24:32+00:00 app[web.1]:   from config.ru:1:in `new 
2012-05-25T18:24:32+00:00 app[web.1]:   from config.ru:1:in `<main> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/rack/adapter/loader.rb:36:in `eval 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/controllers/controller.rb:71:in `start 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/controllers/controller.rb:181:in `load_rackup_config 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/rack/adapter/loader.rb:36:in `load 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:151:in `run! 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/bin/thin:6:in `<top (required)> 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:185:in `run_command 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load 
2012-05-25T18:24:32+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main> 
2012-05-25T18:24:33+00:00 heroku[web.1]: Process exited with status 1
2012-05-25T18:24:33+00:00 heroku[web.1]: State changed from starting to crashed
最佳回答

解答 : 如果您的用户模式位于 app/ model/ User.rb 中, 那么将此文件重命名为 app/model/user.rb , 这样文件的大小写会小一些 。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签