Search code examples
ruby-on-railsdeviserubygems

ruby on rails 5.1 error with devise gem


When I try to run: 'rails generate devise:install'

I am getting the following:

`There was an error while trying to load the gem 'devise'.
Gem Load Error is: undefined method `alias_method_chain' for
ActionDispatch::Routing::RouteSet:Class
Did you mean?  alias_method`

My Gemfile: source 'https://rubygems.org'

gem 'devise'
gem 'rails', '~> 5.1.0'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13.0'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Solution

  • According to https://github.com/plataformatec/devise/issues/4518 Devise 4.0 doesn't work with Rails 5.1.0

    Next week there will be a new release, meanwhile in your Gemfile you can use: gem "devise", git: 'https://github.com/plataformatec/devise.git'