【问题标题】:rake db:migrate error (Migrations are pending)rake db:migrate 错误(迁移待定)
【发布时间】:2017-02-05 05:24:41
【问题描述】:

我一直在寻找解决问题的方法,但没有任何运气。我是一个遵循教程的初学者,我已经到了必须运行命令“rake db:migrate”并不断收到错误的地步。

$ rake db:migrate
== 20160927120721 CreateTodoItems: migrating ==================================
-- create_table(:todo_items)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `refrences' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x0055d8b19b8298>
Did you mean?  references
/home/paul/todo/db/migrate/20160927120721_create_todo_items.rb:5:in `block in change'
/home/paul/todo/db/migrate/20160927120721_create_todo_items.rb:3:in `change'
NoMethodError: undefined method `refrences' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x0055d8b19b8298>
Did you mean?  references
/home/paul/todo/db/migrate/20160927120721_create_todo_items.rb:5:in `block in change'
/home/paul/todo/db/migrate/20160927120721_create_todo_items.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

我尝试使用“rake db:reset”重置 rake,但它告诉我有一个待定迁移并尝试“rake db:migrate”。我还尝试了 'rake db:drop' 'gem update rake' 'bundle update rake' 'bunlde exec rake db:migrate' 仍然没有运气。有人可以帮助我吗?我对这一切都很陌生,所以如果还有什么我可以发布的,请告诉我,这样我才能继续成长和学习!提前致谢!!

Ubuntu 16.04LTS
Rails 4.2.6
ruby 2.3.1p112(2016-04-26 修订版 54768)[x86_64-linux]

【问题讨论】:

  • refrences 更改为 references,就像 rails 给你的建议一样。

标签: ruby-on-rails ruby activerecord rubygems


【解决方案1】:

如您的错误所述,将第 5 行的 20160927120721_create_todo_items.rb 中的 refrences 更改为有效的 references

始终仔细阅读 Rails 的异常 - 它们通常提供丰富的信息。

【讨论】:

  • @paulkiio 如果这解决了您的问题,请确保接受答案(左侧的复选标记)。每个问题您只能接受一个答案。
【解决方案2】:

在您的 20160927120721_create_todo_items.rb 文件中,您输入了错误的 refrences,将其更改为 references

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-17
    • 2013-11-28
    • 1970-01-01
    • 2018-10-06
    • 2017-01-07
    • 2014-02-08
    • 2012-01-25
    • 1970-01-01
    相关资源
    最近更新 更多