简体   繁体   English

当运行“ rails generate devise:install”时,从devise中得到错误“用户不响应'devise'方法”

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

I'm getting error from devise "User does not respond to 'devise' method" when running "rails generate devise:install". 当运行“ rails generate devise:install”时,我从devise中收到错误消息“用户未响应'devise'方法”。 Ideas re how to resolve? 想法重新如何解决?

In fact also get this error when trying to run "rails generate devise:install" I just noted. 实际上,当我尝试运行“ rails generate devise:install”时,也会出现此错误。

Notes: 笔记:

Gregs-MacBook-Pro:testapp greg$ rails generate devise:install
/Library/Ruby/Gems/1.8/gems/devise-2.0.1/lib/devise/rails/routes.rb:406:in `raise_no_devise_method_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)
    from /Library/Ruby/Gems/1.8/gems/devise-2.0.1/lib/devise/rails/routes.rb:207:in `devise_for'
    from /Library/Ruby/Gems/1.8/gems/devise-2.0.1/lib/devise/rails/routes.rb:203:in `each'
    from /Library/Ruby/Gems/1.8/gems/devise-2.0.1/lib/devise/rails/routes.rb:203:in `devise_for'
    from /Users/greg/source_rails/testapp/config/routes.rb:2
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:272:in `instance_exec'
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:272:in `eval_block'
    from /Library/Ruby/Gems/1.8/gems/actionpack-3.2.1/lib/action_dispatch/routing/route_set.rb:249:in `draw'

and

Gregs-MacBook-Pro:testapp greg$ ruby -v 
**ruby 1.8.7** (2010-01-10 patchlevel 249) [universal-darwin11.0]

Gregs-MacBook-Pro:testapp greg$ rails -v
**Rails 3.2.1**

Gregs-MacBook-Pro:testapp greg$ gem list

*** LOCAL GEMS ***

actionmailer (3.2.1)
actionpack (3.2.1)
activemodel (3.2.1)
activerecord (3.2.1)
activeresource (3.2.1)
activesupport (3.2.1)
addressable (2.2.6)
arel (3.0.0)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.22)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
devise (2.0.1)
erubis (2.7.0)
execjs (1.3.0)
faraday (0.7.6)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.1)
jquery-rails (2.0.0)
json (1.6.5)
mail (2.4.1)
mime-types (1.17.2)
multi_json (1.0.4)
multipart-post (1.1.4)
mysql (2.8.1)
mysql2 (0.3.11)
oauth (0.4.5)
oauth-plugin (0.4.0.rc2)
oauth2 (0.5.2)
orm_adapter (0.0.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.1)
railties (3.2.1)
rake (0.9.2.2)
rdoc (3.12)
rubygems-update (1.8.15)
sass (3.1.15, 3.1.14)
sass-rails (3.2.4)
sprockets (2.1.2)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)
uglifier (1.2.3)
warden (1.1.0)

It sounds like you already have the devise method being called in your User model. 听起来您已经在User模型中调用了devise方法。 Perhaps you already ran rails g devise User ? 也许您已经运行过rails g devise User

Comment that out, and comment out the devise_for :users line in your routes file, if that is in there. 注释掉它,然后注释掉route文件中的devise_for :users行(如果在其中)。

Completing a tutorial for rails & these answers didn't work for me, but after some searching found a solution. 完成关于Rails和这些答案的教程对我不起作用,但是经过一番搜索后找到了解决方案。 Hope this helps anyone else who's new and running into this issue. 希望这对其他新手和遇到此问题的人有所帮助。

  1. Go to: config/routes.rb file 转到: config / routes.rb文件
  2. Comment out the line devise_for :installs (put a hash tag in front) devise_for :installs (在前面放一个devise_for :installs
  3. Go to your Ruby terminal and re-enter: rails generate devise:install 转到Ruby终端,然后重新输入: rails generate devise:install

Now Devise should install properly & subsequent errors should be gone. 现在,Devise应该可以正确安装并且以后的错误也应该消失了。

Source 资源

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. 这通常意味着您尚未加载ORM文件,或者加载时间太晚。 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) 要解决此问题,请确保在“ config / initializers / devise.rb”内部或在“ config / application.rb”中的应用程序定义之前要求“ devise / orm / YOUR_ORM”(RuntimeError)

but you already have your ORM initialized properly, it may be gem related. 但是您已经正确初始化了ORM,这可能与gem有关。 I was getting the same problem on an old app and it was due to an incompatibility with the active_reload gem. 我在旧的应用程序上遇到了同样的问题,这是由于与active_reload gem不兼容active_reload gem active_reload is not compatible with Rails 3.2 and should be removed. gem active_reload与Rails 3.2不兼容,应将其删除。 active_reload has been incorporated into Rails 3.2, so it's safe to remove. active_reload已被合并到Rails 3.2中,因此可以安全删除。

I got the solution from here: http://anlek.com/2012/02/user-does-not-respond-to-devise-method/ 我从这里获得了解决方案: http : //anlek.com/2012/02/user-does-not-respond-to-devise-method/

i had this same problem. 我有同样的问题。 however for me it was caused by a conflict with the active_reload gem. 但是对我来说,这是由于与active_reload gem冲突引起的。 once i removed that all was well. 一旦我删除,一切都很好。 i got the tip from https://github.com/plataformatec/devise/issues/1597 我从https://github.com/plataformatec/devise/issues/1597获得了提示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM