Devise: undefined method `alias_method_chain (Rails 5.1, ruby 2.4)

Created on 28 Apr 2017  路  16Comments  路  Source: heartcombo/devise

gem 'devise'

error:

/Users/kota/.rvm/rubies/ruby-2.4.0/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/kota/Projects/Freya/bin/rails server -b 0.0.0.0 -p 3000 -e development
/Users/kota/.rvm/gems/ruby-2.4.0@Freya/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'devise'. (Bundler::GemRequireError)
Gem Load Error is: undefined method `alias_method_chain' for ActionDispatch::Routing::RouteSet:Class
Did you mean?  alias_method
Backtrace for gem load error is:

Most helpful comment

fixed

add:

gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'
bundle install

working for me.

All 16 comments

fixed

add:

gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'
bundle install

working for me.

Could you try the master branch? It should be fixed there.

@rafaelfranca just tried the master branch with ruby 2.4.1 and rails 5.1 and it is not working.

Resolving dependencies...
Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    devise was resolved to 4.2.0, which depends on
      railties (< 5.1, >= 4.1.0)

    rails (~> 5.1.0) was resolved to 5.1.0, which depends on
      railties (= 5.1.0)

Sorry, my mistake, it is working!

@imKota Thank you for taking the time to post your solution to the problem.
I had the same issue, and i have implemented your fix.

But. Would you be able to explain what is actually happening here?
What is special about 'gogovan/devise.git' and the 'erubis' gem?

Thank you in advance! 馃槃

hola hablo espa帽ol soy nuevo me gustaria que me ayudaran estoy instalando devise pero cuando coloco "rails g devise:install"
da resultado esto
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:85:in rescue in block (2 levels) in require': There was an error while trying to loa d the gem 'devise'. (Bundler::GemRequireError) Gem Load Error is: undefined methodalias_method_chain' for ActionDispatch::Routing::RouteSet:Class
Did you mean? alias_method
Backtrace for gem load error is:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:14:in <class:RouteSet>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:2:in'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:1:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in block in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:inload_dependency'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails.rb:1:in C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inblock in require'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in load_dependency' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise.rb:445:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:82:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:82:in block (2 levels) in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:ineach'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:in block in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:ineach'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler.rb:108:inrequire'
C:/Users/admin/certificados/config/application.rb:7:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:in require_application_and_environment!' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands/generate/generate_command.rb:19:inperform'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in run' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:ininvoke_command'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in dispatch' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/base.rb:63:inperform'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command.rb:44:in invoke' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands.rb:16:in bin/rails:4:in require' bin/rails:4:in

'
Bundler Error Backtrace:
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:81:in block (2 levels) in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:ineach'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:in block in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:ineach'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler.rb:108:inrequire'
from C:/Users/admin/certificados/config/application.rb:7:in <top (required)>' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:inrequire'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:in require_application_and_environment!' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands/generate/generate_command.rb:19:inperform'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in run' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:ininvoke_command'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in dispatch' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/base.rb:63:inperform'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command.rb:44:in invoke' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands.rb:16:in from bin/rails:4:in require' from bin/rails:4:in
'

C:Usersadmincertificados>gem update bundlergem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
Updating installed gems
Nothing to update

C:Usersadmincertificados>rails generate devise:install
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:85:in rescue in block (2 levels) in require': There was an error while trying to loa d the gem 'devise'. (Bundler::GemRequireError) Gem Load Error is: undefined methodalias_method_chain' for ActionDispatch::Routing::RouteSet:Class
Did you mean? alias_method
Backtrace for gem load error is:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:14:in <class:RouteSet>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:2:in'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails/routes.rb:1:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in block in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:inload_dependency'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise/rails.rb:1:in C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inblock in require'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in load_dependency' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/devise-1.5.4/lib/devise.rb:445:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:82:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:82:in block (2 levels) in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:ineach'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:in block in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:ineach'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:in require' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler.rb:108:inrequire'
C:/Users/admin/certificados/config/application.rb:7:in <top (required)>' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:inrequire'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:in require_application_and_environment!' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands/generate/generate_command.rb:19:inperform'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in run' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:ininvoke_command'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in dispatch' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/base.rb:63:inperform'
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command.rb:44:in invoke' C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands.rb:16:in bin/rails:4:in require' bin/rails:4:in

'
Bundler Error Backtrace:
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:81:in block (2 levels) in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:ineach'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:77:in block in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:ineach'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler/runtime.rb:66:in require' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.15.0.pre.3/lib/bundler.rb:108:inrequire'
from C:/Users/admin/certificados/config/application.rb:7:in <top (required)>' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:inrequire'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/actions.rb:15:in require_application_and_environment!' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands/generate/generate_command.rb:19:inperform'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in run' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:ininvoke_command'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in dispatch' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command/base.rb:63:inperform'
from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/command.rb:44:in invoke' from C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.1.0/lib/rails/commands.rb:16:in from bin/rails:4:in require' from bin/rails:4:in
'

This fails for devise-async though:

Gemfile:

gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'
gem 'devise-async'

Results:

Bundler could not find compatible versions for gem "devise":
  In Gemfile:
    devise

    devise-async was resolved to 0.5.1, which depends on
      devise (< 2.2.0, >= 1.1)

@NickMoignard Special? fixed version.
When installing devise, a dependency error appeared. What you need to install erubis. After installing 'gogovan/devise.git and erubis, it all worked for me.

Try the master branch.
#4518 (comment)

@repocho007 Hola bro la solucion la dio imKota, igual es solo editar el archivo Gemfile dentro del proyecto y colocas:

gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'

Luego en la consola ejecutas
bundle install

Y ya podras: rails g device:install

Friend ya e solucionado
lo solucione con la desinstalacion del development e instalandolo depues de ello instale teniendo en cuenta el review despues de init seguido por install con ayuda de node y ruby main logre instalar todo lo faltante

Zelgaliz veo que hablas espa帽ol sera que me podr铆as colaborar con algunos asustos de unas gemas
ya que soy nuevo en el tema

The master branch has the fix already.

Confirmed master branch working well!
gem 'devise', git: 'https://github.com/plataformatec/devise.git', branch: 'master'

Yup, confirmed. Thanks!!

@rafaelfranca is there any plan in which version will this be added - i.e. not just on the master branch, but bundled up to rubygems.org?

undefined method `alias_method_chain' for DeviseController:Class (NoMethodError) when we are using the devise version i.e gem 'devise', git: 'https://github.com/plataformatec/devise.git', branch: 'master' in rails 5.1.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spaquet picture spaquet  路  3Comments

afuno picture afuno  路  3Comments

edipox picture edipox  路  4Comments

mits87 picture mits87  路  3Comments

cheung-chifung picture cheung-chifung  路  4Comments