getting error from devise “User does not respond to 'devise' method” when running “rails generate devise:install”

前端 未结 4 936
星月不相逢
星月不相逢 2021-02-09 07:10

I\'m getting error from devise \"User does not respond to \'devise\' method\" when running \"rails generate devise:install\". Ideas re how to resolve?

In fact also get

相关标签:
4条回答
  • 2021-02-09 07:18

    It sounds like you already have the devise method being called in your User model. Perhaps you already ran rails g devise User ?

    Comment that out, and comment out the devise_for :users line in your routes file, if that is in there.

    0 讨论(0)
  • 2021-02-09 07:27

    i had this same problem. however for me it was caused by a conflict with the active_reload gem. once i removed that all was well. i got the tip from https://github.com/plataformatec/devise/issues/1597

    0 讨论(0)
  • 2021-02-09 07:31

    For people that arrived here due to the following error:

    User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)

    but you already have your ORM initialized properly, it may be gem related. I was getting the same problem on an old app and it was due to an incompatibility with the active_reload gem. gem active_reload is not compatible with Rails 3.2 and should be removed. active_reload has been incorporated into Rails 3.2, so it's safe to remove.

    I got the solution from here: http://anlek.com/2012/02/user-does-not-respond-to-devise-method/

    0 讨论(0)
  • 2021-02-09 07:37

    Completing a tutorial for rails & these answers didn't work for me, but after some searching found a solution. Hope this helps anyone else who's new and running into this issue.

    1. Go to: config/routes.rb file
    2. Comment out the line devise_for :installs (put a hash tag in front)
    3. Go to your Ruby terminal and re-enter: rails generate devise:install

    Now Devise should install properly & subsequent errors should be gone.

    Source

    0 讨论(0)
提交回复
热议问题