Rails devise error "NoMethodError ... merge"
I was trying to make a User model with devise (so far in my application I have not had a problem with making Models or adding attributes). I run
rails g devise user
Which creates this:
invoke active_record create db/migrate/20140930235224_devise_create_users.rb create app/models/user.rb invoke test_unit create test/models/user_test.rb create test/fixtures/users.yml insert app/models/user.rb route devise_for :users
Then I try to run
Which gives me the following
rake aborted! NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x9fc73a4> /home/user/Desktop/MyApp/config/routes.rb:2:in `block in <top (required)>' /home/user/Desktop/MyApp/config/routes.rb:1:in `<top (required)>' /home/user/Desktop/MyApp/config/environment.rb:5:in `<top (required)>' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace)
What could be the problem?
Line 2 for routes is:
And line 5 for environment is:
It looks like this may be a problem with Devise and the latest version of Rails. Have a look at these issues on Devise Github:
This blog post explains that there is a branch with the fix, however, if you are going to be using this in production you should probably wait until Devise merge the fix into master.
Check what devise version you have installed by running:
bundle show devise
With the latest version of Rails 4.2.0, devise will need to be upgraded to 3.4.0 or higher. To do so, specify in your Gemfile:
gem 'devise', '~> 3.4.0'
bundle update devise
Updating the version of devise from 3.3.0 to 3.4.0 in my Gemfile and running bundle update devise worked like magic for me. Im running rails 4.2.0.