问题描述
我试图按照,但在创建简单的新项目之后,添加 gem'devise'
并运行 bundle install
,但是当我运行 rails生成devise:install
我收到一个错误开始
错误:获取可用的生成器脚本执行错误:
错误:C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/ 1.9.1 / gems / activerecord-4.1.1 / lib / active_record / dynamic_matchers.rb:26:在`method_missing'中:用于用户的未定义方法`devise'(调用'User.connection'建立连接):Class(NoMethodError )
有谁知道我可能做错了什么? (我尝试使用devise wiki中的说明,但是我也不能这样做)。
我刚刚遇到了同样的问题,这是因为您尝试在尝试安装设计之前尝试生成该模型。 b
将用户模型的更改保存(或删除)和任何迁移文件,然后运行这个
rails generate devise:install
pre>
在此之后,您可以卸载并应用迁移,它应该可以正常运行。
I'm trying to get user authentication with devise working, and failing.
I tried following the steps in the RailsGirls article, but after creating the simple new project, adding the
gem 'devise'
and runningbundle install
, but when I runrails generate devise:install
I get a screenful of errors startingError:Get available generators script executes with errors: Error:C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.1.1/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined method `devise' for User (call 'User.connection' to establish a connection):Class (NoMethodError)
Has anybody any idea what I might be doing wrong? (I tried using the instructions in the devise wiki, but I couldn't get it working that way either).
解决方案I just ran to this same problem today, it's because you tried to generate the model before you tried to install devise it self
Stash ( or remove ) the changes for the user model and any migration file, then run this
rails generate devise:install
after that unstash and apply the migration, it should work just fine.
这篇关于如何使用devise和Rails 4设置用户身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!