db/migrate/20150519124846_remove_unstandardized_custom_languages.rb
# Redefine all Active Record models, so that the migration doesn't depend on the version of code
Redefine all Active Record models, so that the migration doesn't depend on the version of code
Redefine all Active Record models so that the migration doesn ' t depend on the version of code
def change_locale(community:, from:, to:)
    [
      community.categories.flat_map(&:translations),
      community.community_customizations,
      community.custom_fields.flat_map(&:names),
      community.custom_fields.flat_map(&:options).flat_map(&:titles),
      community.menu_links.flat_map(&:translations)
    ].map do |models|
      models.select { |m| m.locale == from }
    end.each do |models|
      change_model_locale(models, to)
    end
    MigrationModel::CommunityTranslation.where(community_id: community.id, locale: from).update_all(locale: to)
    Rails.cache.delete("/translation_service/community/#{community.id}")
  end
def change_locale ( community : , from : , to : ) [ community . categories . flat_map ( & :translations ) , community . community_customizations , community . custom_fields . flat_map ( & :names ) , community . custom_fields . flat_map ( & :options ) . flat_map ( & :titles ) , community . menu_links . flat_map ( & :translations ) ] . map do | models | models . select { | m | m . locale == from } end . each do | models | change_model_locale ( models , to ) end MigrationModel :: CommunityTranslation . where ( community_id : community . id , locale : from ) . update_all ( locale : to ) Rails . cache . delete ( "/translation_service/community/#{community.id}" ) end
Redefine all Active Record models, so that the migration doesn't depend on the version of code
Redefine all Active Record models so that the migration doesn ' t depend on the version of code
community
from
to