我正在使用全球化来翻译消息,并且我使用它来迁移现有数据。这些列之一是json类型。在执行迁移之后,该json数据被更改为String,它似乎自动运行了to_json方法。我该怎么做才能迁移数据并保持json类型
dir.up do
I18n.with_locale(:en) do
Pigeon::Alert.create_translation_table!({
subject: :string,
message: :text,
unlayer_message: :json,
}, {
:migrate_data => true,
:remove_source_columns => true
})
end
end
concerning :Locale do
included do
translates :subject, :message, :unlayer_message, fallbacks_for_empty_translations: true
globalize_accessors
default_scope { preload(:translations) }
attr_accessor :locale
end
end