2

I'm very new to Rails, and I'm trying to build a user authentication system with 'devise', but I am failing. I'm following Rails Girls Guides's tutorial on adding authentication using the gem 'devise'. Once I got to step 5, which is to set up the User model, I received this error after running rake db:migrate

rake aborted!
NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x007fd3397a7448>
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `ensure in with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:420:in `with_devise_exclusive_scope'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:233:in `block (2 levels) in devise_for'
/Users/.rvm/gems/ruby-2.1.2/gems/devise-3.0.4/lib/devise/rails/routes.rb:336:in `block in devise_scope'

Has anyone solved this error? I've looked at all solutions such as not generating user model before installing devise, running bundle install, running rails g devise:install, and more. Nothing has worked so far when I'm trying to use devise for Rails 4.0.

Also, does anyone have recommendations on what tutorials I can follow to build an authentication system? I've tried a lot so far, and none has worked.

Community
  • 1
  • 1
cs-nerd
  • 73
  • 7
  • please do `rails -v` to check if you are using rails 4.0 or 4.2. This looks to be just affecting rails 4.2 as seen here https://github.com/plataformatec/devise/issues/3158 – Ismael Abreu Jan 21 '15 at 01:18
  • My version is 4.2, so I believe you are correct to suspect this. How do I change my rails version? – cs-nerd Jan 21 '15 at 01:20
  • This issue happens to be already fixed on devise. Can you check what version of devise you are using? You can run this to check it `bundle list | grep devise` – Ismael Abreu Jan 21 '15 at 01:22
  • I'm using devise 3.4.1 – cs-nerd Jan 21 '15 at 01:30
  • no you are not. I just realised the devise version is at the error backtrace you posted :) `ruby-2.1.2/gems/devise-3.0.4` – Ismael Abreu Jan 21 '15 at 01:32

1 Answers1

3

This looks to be a know bug with prior 3.4.0 devise.

Upgrading it should make this error go away.

To do that edit your Gemfile where you have gem "devise" <might have some other stuff in front> and change it to gem "devise", '~> 3.4.1'

then run bundle update devise and you are done.

Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75