migrate_data:true is not working.
gomo opened this issue · 1 comments
gomo commented
'activerecord', '5.2.6'
'globalize', '5.1.0', tried with '5.3.1' too
class I18nMenuPrice < ActiveRecord::Migration[5.2]
def change
I18n.with_locale(:ja) do
Menu.add_translation_fields!({
price: :integer,
}, {
:migrate_data => true,
:remove_source_columns => true
})
end
end
end
I need to translate
the Model to do migration
.
class Menu < ApplicationRecord
translates :price
If I don't do this, I can't do the migration with the following error.
Globalize::ActiveRecord::Exceptions::BadFieldName: Missing translated field :price
However, if I put translates :price
in the model, it doesn't get the column value.
[1] pry(main)> Menu.first
Menu Load (0.2ms) SELECT `menus`. `id`, `menus`. `sequence`, `menus`. `parent_id`, `menus`. `menu_type_id`, `menus`. `image`, `menus`. `is_set`, `menus`. `link_url`, `menus`. `created_at`, `menus`. `updated_at` FROM `menus` ORDER BY `menus`. `id` ASC LIMIT 1
I think record.read_attribute(attribute_name, {:translated => false})
in move_data_to_translation_table
will always return nil.
Am I doing something wrong?
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.