我有一个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!'
问题来自设计,但我不知道如何解决它。 我的模型User已正确定义,并且可以在我的计算机上运行... 有谁知道如何解决这个问题?
谢谢你的帮助
答案 0 :(得分:2)
确保你有这个:
class User < ActiveRecord::Base
定义在用户/设计模型的顶部。
另外,请确保您运行迁移。
heroku rake db:migrate
在控制台中。
答案 1 :(得分:1)
检查您的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