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

Defined in:
lib/batch_translations.rb

Instance Method Summary collapse

Instance Method Details

#after_saveObject



58
59
60
# File 'lib/batch_translations.rb', line 58

def after_save
  init_translations
end

#init_translationsObject

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



63
64
65
66
67
68
69
70
71
# File 'lib/batch_translations.rb', line 63

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