What's the easiest way to add translation capabilities to an existing model and automatically migrate the existing records?
The globalize gem provides a method create_translation_table
with an option migrate_data: true
, is there an equivalent for mobility?
The only workaround I found when working with the gem using the :key_value Strategy is to create a migration for each table and re-saving the value of the column using
[:column_name]
Example: If we Have a Post Table and I want to add it's name attribute to translations: The Mobility migration(s) must be executed and
post.rb
must include:Then update the records to reflect the value of the default language (assuming
application.rb
hasconfig.i18n.default_locale = :de
andinitializers/mobility.rb
defineslocale_accessors [:de, :en, :sl]
Then verify: