gpt4 book ai didi

ruby-on-rails - Rails5 迁移 : can't quote Array

转载 作者:行者123 更新时间:2023-12-04 06:22:55 27 4
gpt4 key购买 nike

我尝试将我的应用程序从 Rails 4 迁移到 Rails 5
这是我的迁移:

class AddRevealedIdsToUser < ActiveRecord::Migration[5.0]
def change
add_column :users, :revealed_ids, :text, default: []
end
end

和型号:
serialize :revealed_ids

它在 Rails 4 中工作得很好,现在我有一个错误:
== 20160416214334 AddRevealedIdsToUser: migrating =============================
-- add_column(:users, :revealed_ids, :text, {:default=>[]})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

can't quote Array
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/quoting.rb:177:in `_quote'
/usr/local/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/quoting.rb:96:in `_quote'

怎么解决?

最佳答案

作为临时解决方案,我手动将其序列化。

add_column :users, :revealed_ids, :text, default: [].to_yaml

在 Rails 存储库中打开了一个问题。

关于ruby-on-rails - Rails5 迁移 : can't quote Array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38953885/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com