为了账号安全,请及时绑定邮箱和手机立即绑定

脚手架后无法迁移数据库。2.2节Ruby on Rails教程Michael Hartl

脚手架后无法迁移数据库。2.2节Ruby on Rails教程Michael Hartl

浮云间 2019-12-02 13:17:36
我正在阅读Hartl ruby on rails教程(第2.2节),而在迁移数据库时遇到了麻烦。一切似乎都正常,然后我运行rails generate scaffold User name:string email:string 之后,我尝试运行包exec rake db:migrate并收到以下错误消息:$ bundle exec rake db:migrate                                                                                 == 20141125234257 CreateUsers: migrating ======================================-- create_table(:users)   -> 0.0079s== 20141125234257 CreateUsers: migrated (0.0080s) =============================rake aborted!StandardError: An error has occurred, this and all later migrations canceled:wrong number of arguments (1 for 0)/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'/usr/local/rvm/gems/ruby-2.1.4@rails4/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'Tasks: TOP => db:migrate(See full trace by running task with --trace)我尝试返回到较早的提交,然后再次运行所有内容,但收到相同的错误消息。我是否还应该添加其他文件来帮助解决此问题?
查看完整描述

3 回答

?
尚方宝剑之说

TA贡献1788条经验 获得超4个赞

以上更改gemfile的解决方案。


 gem 'arel', '6.0.0.beta2'

我收到以下错误消息。


You have requested:arel = 6.0.0.beta2


The bundle currently has arel locked at 6.0.0.

Try running `bundle update arel`


bundle update arel    

有效


查看完整回答
反对 回复 2019-12-02
?
侃侃尔雅

TA贡献1801条经验 获得超15个赞

我已经解决了


rake db:reset

之后


rake db:migrate

工作了。


查看完整回答
反对 回复 2019-12-02
  • 3 回答
  • 0 关注
  • 630 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信