简体   繁体   English

Rails设计错误“NoMethodError ... merge”

[英]Rails devise error “NoMethodError … merge”

I was trying to make a User model with devise (so far in my application I have not had a problem with making Models or adding attributes). 我试图用设计制作用户模型(到目前为止,在我的应用程序中,我没有制作模型或添加属性的问题)。 I run 我跑

rails g devise user

Which creates this: 这创造了这个:

  invoke  active_record
  create    db/migrate/20140930235224_devise_create_users.rb
  create    app/models/user.rb
  invoke    test_unit
  create      test/models/user_test.rb
  create      test/fixtures/users.yml
  insert    app/models/user.rb
  route  devise_for :users

Then I try to run 然后我试着跑

rake db:migrate

Which gives me the following 这给了我以下几点

rake aborted!
NoMethodError: undefined method `merge!' for #<ActionDispatch::Routing::Mapper::Scope:0x9fc73a4>
/home/user/Desktop/MyApp/config/routes.rb:2:in `block in <top (required)>'
/home/user/Desktop/MyApp/config/routes.rb:1:in `<top (required)>'
/home/user/Desktop/MyApp/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

What could be the problem? 可能是什么问题呢?

Line 2 for routes is: 路线2是:

devise_for :users

And line 5 for environment is: 环境的第5行是:

Rails.application.initialize!

Check what devise version you have installed by running: 通过运行检查已安装的设备版本:

bundle show devise

With the latest version of Rails 4.2.0, devise will need to be upgraded to 3.4.0 or higher. 使用最新版本的Rails 4.2.0,设计需要升级到3.4.0或更高版本。 To do so, specify in your Gemfile: 为此,请在Gemfile中指定:

gem 'devise', '~> 3.4.0'

Then run: 然后运行:

bundle update devise

It looks like this may be a problem with Devise and the latest version of Rails. 看起来这可能是Devise和最新版Rails的问题。 Have a look at these issues on Devise Github: 在Devise Github上看看这些问题:

This blog post explains that there is a branch with the fix, however, if you are going to be using this in production you should probably wait until Devise merge the fix into master. 这篇博客文章解释说有一个修复分支,但是,如果你打算在生产中使用它,你应该等到Devise将修复合并到master。

Updating the version of devise from 3.3.0 to 3.4.0 in my Gemfile and running bundle update devise worked like magic for me. 在我的Gemfile中将设备版本从3.3.0更新到3.4.0并运行bundle update devise对我来说就像魔术一样。 Im running rails 4.2.0. 我正在运行rails 4.2.0。

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

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