【发布时间】:2016-05-14 09:02:43
【问题描述】:
有人提出了类似的问题,但没有一个建议对我有用。我正在尝试在我的计算机上迁移 Rails 开发中的数据库,但我不断收到此错误消息:
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined local variable or method `total' for #<CreateProfessors:0x007f8ce3ca4e60>/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:664:in `block in method_missing'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord- 4.2.5.1/lib/active_record/migration.rb:634:in `block in say_with_time'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:634:in `say_with_time'
/Users/tfantina/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:654:in `method_missing'
它持续了一百行左右。
这里的一篇帖子建议删除
null: false
来自
t.timestamps null:false
我做到了。
我尝试过的另一个建议是运行 db:drop:all 然后 db:create:all 然后 db:migrate。
为了确保 sqlite3 在我的 OSX 上,我在终端中运行了 sqlite3 查询并返回:SQLite 版本 3.8.10.2 所以我认为它工作正常。
迁移失败:
class CreateProfessors < ActiveRecord::Migration
def change
create_table :professors do |t|
t.string :fname
t.string :lname
t.decimal :rating-total
t.decimal :rating-hw
t.decimal :rating-test
t.decimal :rating-interest
t.text :comments
t.string :ease
t.timestamps
end
end
end
【问题讨论】:
-
请粘贴上一次迁移或失败的迁移
-
我添加了失败的迁移,这是我目前唯一完成的迁移。
标签: ruby-on-rails sqlite dbmigrate