Module: Translatable::Concern
- Extended by:
- ActiveSupport::Concern
- Included in:
- Translatable
- Defined in:
- lib/translatable/concern.rb
Defined Under Namespace
Classes: DatabaseColumnConflictError, Error, MissingTranslationsColumnError, UndefinedTranslatableFieldsError
Instance Method Summary collapse
Instance Method Details
#initialize_translations ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/translatable/concern.rb', line 97 def initialize_translations self.class.validate_translatable column_name = self.class.translations_column_name.to_s current_translations = send(column_name) || {} self.class.translatable_locales.map(&:to_s).uniq.each do |locale| current_translations[locale] ||= {} self.class.translatable_fields.map(&:to_s).uniq.each do |field| unless current_translations[locale].key?(field) current_translations[locale][field] = nil end end end send("#{column_name}=", current_translations) end |