Heroku 您提供了devise_for:users但您的应用程序中没有用户定义的模型

我有一个rails 3(3.0.9)应用程序在ruby 1.8.7上工作,我的计算机上的gem devise(1.4.2)工作得很好。

我试图在heroku上推送它,我在应用程序加载时收到以下错误消息:

[WARNING] You provided devise_for :users but there is no model User defined in your application => Booting WEBrick => Rails 3.0.9 application starting in production on http://0.0.0.0:43292 => Call with -d to detach => Ctrl-C to shutdown server Exiting /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/inflector/methods.rb:124:in `block in constantize': uninitialized constant User (NameError) from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/inflector/methods.rb:123:in `each' from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/inflector/methods.rb:123:in `constantize' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise/mapping.rb:84:in `to' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise/mapping.rb:79:in `modules' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise/mapping.rb:88:in `strategies' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise.rb:410:in `block in configure_warden!' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise.rb:409:in `each_value' from /app/vendor/bundle/ruby/1.9.1/gems/devise-1.4.2/lib/devise.rb:409:in `configure_warden!' 

问题来自设计,但我不知道如何解决它。 我的模型用户已正确定义,它可以在我的计算机上运行…有谁知道如何解决这个问题?

谢谢你的帮助

确保你有这个:

 class User < ActiveRecord::Base 

定义在用户/设计模型的顶部。

另外,请确保运行迁移。

 heroku rake db:migrate 

在控制台中。

检查您的users.rb内部以确保正确拼写’:database_authenticable’,这似乎是此错误的常见问题。

 class User < ActiveRecord::Base devise :database_authenticable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me end 

此外,我建议你看看这里,看看这些人如何修复错误。 http://groups.google.com/group/plataformatec-devise/browse_thread/thread/807f4c6e3475622f