Heroku [WARNING] You provided devise_for :users but there is no model User defined in your application

僤鯓⒐⒋嵵緔 提交于 2020-01-05 07:26:09

问题


I have an rails 3 (3.0.9) application working on ruby 1.8.7 with the gem devise (1.4.2) on my computer working perfectly.

I tried to push it on heroku and i got the following error message on application load:

[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!'

The problem comes from devise but i don't know how to fix it. My model User is correctly defined, and it works on my computer... Does anyone know how to fix this ?

Thanks for you help


回答1:


Make sure you have this:

class User < ActiveRecord::Base

Defined at the top of your user/devise model.

ALso, make sure you run your migrations.

heroku rake db:migrate

In console.




回答2:


Check inside your users.rb to make sure that you spelled ':database_authenticable' correctly, this seems to be a common problem with this error.

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

Also, I suggest you take a look here, to see how these people fixed the error. http://groups.google.com/group/plataformatec-devise/browse_thread/thread/807f4c6e3475622f



来源:https://stackoverflow.com/questions/6866371/heroku-warning-you-provided-devise-for-users-but-there-is-no-model-user-defin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!