Error creating Rails "NoMethodError ... merge"

I tried to create a User model with the application (while in my application I had no problem creating models or adding attributes). I launched

rails g devise user 

What 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

 rake db:migrate 

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:

 devise_for :users 

And line 5 for the environment:

 Rails.application.initialize! 
+5
source share
3 answers

It seems like this could be a problem with Devise and the latest version of Rails. Take a look at these issues on Devise Github:

This blog post explains that there is a patch branch, however, if you intend to use this in the production process, you should probably wait until Devise merges the patch into master.

+2
source

Check which version you installed by doing:

 bundle show devise 

With the latest version of Rails 4.2.0, development must be updated to 3.4.0 or higher. To do this, specify in your Gemfile:

 gem 'devise', '~> 3.4.0' 

Then run:

 bundle update devise 
+22
source

Upgrading the devise version from 3.3.0 to 3.4.0 in my Gemfile and starting the package upgrade worked like magic for me. Im working rails 4.2.0.

+1
source

Source: https://habr.com/ru/post/1203755/


All Articles