Module: Globalize::Model::ActiveRecord::Translated::InstanceMethods

Defined in:
lib/models/model.rb

Instance Method Summary collapse

Instance Method Details

#after_saveObject



11
12
13
# File 'lib/models/model.rb', line 11

def after_save
  init_translations
end

#init_translationsObject

Builds an empty translation for each available locale not in use after creation



16
17
18
19
20
21
22
23
24
# File 'lib/models/model.rb', line 16

def init_translations
  I18n.translated_locales.reject{|key| key == :root }.each do |locale|
    translation = self.translations.find_by_locale locale.to_s
    if translation.nil?
      translations.build :locale => locale
      save
    end
  end
end