Devise error when using Rails 4
You ever run into problems with your code development that's just a pita to debug? Well, I ran into a big one yesterday. I spent hours searching for a solution.
It seems that when using Devise with Rails 4, you could run into problems where you get this long error that looks something like this whenever you try to rake:
rake aborted! Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f85bd181060 @paths=["/Users/Mac/rails_projects/limolot/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007f85bd119488>]> /Users/Mac/.rvm/gems/ruby-2.0.0-p247@limolot/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated' /Users/Mac/.rvm/gems/ruby-2.0.0-p247@limolot/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated' /Users/Mac/.rvm/gems/ruby-2.0.0-p247@limolot/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher> ...
So what the heck is that? This is a long running problem that stretches all the way back to earlier this year when Rails 4 was released. It's supposed to be fixed by Devise 3.1.0 but for some reason it still rears its ugly head.
In my case, it was when I was transferring some code from one app to another. I tried all sorts of things to try to fix the problem. This included reinstalling Devise and regenerating the User class. But what I discovered to be a simple fix was to leave whatever devise generated code in the user.rb alone, undisturbed, on the top of the page and to write your code below it. That seems to have worked in my case. Just to clear, here's what the user.rb file in your model folder should look like:
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable ^^^LEAVE THAT JUNK ABOVE ALONE^^^ ***PUT YOUR CODE HERE*** end
I hope this helps someone else out!














