lib/tolk/sync.rb in tolk-1.3.5 vs lib/tolk/sync.rb in tolk-1.3.6
- old
+ new
@@ -36,11 +36,10 @@
private
def sync_phrases(translations)
primary_locale = self.primary_locale
- secondary_locales = self.secondary_locales
# Handle deleted phrases
translations.present? ? Tolk::Phrase.destroy_all(["tolk_phrases.key NOT IN (?)", translations.keys]) : Tolk::Phrase.destroy_all
phrases = Tolk::Phrase.all
@@ -52,15 +51,10 @@
translation = existing_phrase.translations.primary || primary_locale.translations.build(:phrase_id => existing_phrase.id)
translation.text = value
if translation.changed? && !translation.new_record?
# Set the primary updated flag if the primary translation has changed and it is not a new record.
- secondary_locales.each do |locale|
- if existing_translation = existing_phrase.translations.detect {|t| t.locale_id == locale.id }
- existing_translation.force_set_primary_update = true
- existing_translation.save!
- end
- end
+ existing_phrase.translations.update_all({ :primary_updated => true }, Tolk::Translation.arel_table[:locale_id].not_eq(primary_locale.id))
end
translation.primary = true
translation.save!
end