undefined method `devise_for' in rails

Ruby on-RailsMethodsDeviseUndefined

Ruby on-Rails Problem Overview


After I install devise and create a user model. I rake db:migrate and then I rake routes. I then get a error with "undefined method `devise_for' for #". What could be causing this error?

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

Remember to restart your rails server after installing and configuring devise.

Solution 2 - Ruby on-Rails

If you have the Devise gem specified in the Gemfile, just make sure you have the following in your routes.rb file:

 devise_for :users

Also, here's a trick to make sure Devise is mapped properly, run: rails c, (the Rails app console) in your app's folder and then the following command line:

 Devise.mappings.keys

You should see:

=> [:user] 

Cheers!

Solution 3 - Ruby on-Rails

Honestly, I would recommend following these two Railscasts (Episode 209 and Episode 210). The first is a simple and very easy walkthrough for installing Devise and the second is about customizing it to fit your application.

I've watched both episodes and they drastically helped me with Devise, particularly with the customization.

Your best bet is to start from scratch - you'll learn a heck of a lot and have Devise fully installed and functional.

Hope this helps! Good luck.

Solution 4 - Ruby on-Rails

You may need to do a bundle install

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYeddieView Question on Stackoverflow
Solution 1 - Ruby on-RailsSerge PaquetView Answer on Stackoverflow
Solution 2 - Ruby on-RailsFlorinView Answer on Stackoverflow
Solution 3 - Ruby on-RailsvichView Answer on Stackoverflow
Solution 4 - Ruby on-RailsRishav RastogiView Answer on Stackoverflow