尝试在新计算机上启动并运行应用程序。可能使用稍微更新的Ruby版本(2.3.4 vs 2.3.1),Rails版本是5.1.3。
以下是迁移:
class AddDragAndDropRules < ActiveRecord::Migration[5.0]
def change
add_column :products, :fixture_location, :string, default: "none"
add_column :products, :attaches_to, :uuid, array: true, default: []
end
end
rails db:migrate
期间的问题。
错误:
== 20160928162420 AddDragAndDropRules: migrating ==============================
-- add_column(:products, :fixture_location, :string, {:default=>"none"})
-> 0.0142s
-- add_column(:products, :attaches_to, :uuid, {:array=>true, :default=>[]})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
no implicit conversion of Array into String
/Users/mike/api/db/migrate/20160928162420_add_drag_and_drop_rules.rb:4:in `change'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
TypeError: no implicit conversion of Array into String
/Users/mike/api/db/migrate/20160928162420_add_drag_and_drop_rules.rb:4:in `change'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
任何人都能发现错误吗?
答案 0 :(得分:1)
如果这有助于其他任何人 - 该项目在某些时候升级到Rails 5.1.3,导致UUID阵列迁移因错误而失败。
问题在这里(https://github.com/rails/rails/issues/30539),5.1.2-5.1.3中的解决方法是这样做:
add_column :products, :attaches_to, :uuid, array: true, default: '{}'
应在5.1.4及以上版本中修复。