Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise not working due to this warning: [WARNING] You provided devise_for :users but there is no model User defined in your application

I've just added a fresh install of devise to a rails app but it's outputtin a warning on start server start and devise is not working at all:

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

I 100% do have a model called users.

I've had a look about at others with this issue there is this one (Heroku [WARNING] You provided devise_for :users but there is no model User defined in your application) and I've changed the name of ':database_authenticable'. This did not fix it.

Also the devise initializer is set to active record, which is another bug which has this error (require 'devise/orm/active_record'), however this did not fix it either.

Has anyone else has this error, or is there a way I can trace it to get more details? Thanks.

like image 560
MintDeparture Avatar asked Nov 01 '22 11:11

MintDeparture


2 Answers

I think if you have devise_for :users in your routes it will target your user model (singular). You said the name of your model is users, which could make it not work.

like image 81
Philip7899 Avatar answered Nov 13 '22 17:11

Philip7899


Check the model is in app/models/user.rb, not users.rb, and run ruby -c app/models/user.rb to do a syntax check.

If User exists and doesn't have a syntax error, it may be failing to load because it's trying to include something that doesn't exist. Comment out the body of the class and see if Devise lets you run rails console now.

like image 21
pushcx Avatar answered Nov 13 '22 15:11

pushcx