module FormTranslation::ForModel
Public Class Methods
included(base)
click to toggle source
# File lib/form_translation/for_model.rb, line 24 def self.included(base) base.extend ClassMethods end
Public Instance Methods
translate!(language = I18n.locale)
click to toggle source
# File lib/form_translation/for_model.rb, line 16 def translate! language = I18n.locale unless language == FormTranslation.default_language self.class.translated_attrs.each do |a| send "#{a}=", send("#{language}_#{a}") end end end
values_given_for?(lng)
click to toggle source
# File lib/form_translation/for_model.rb, line 3 def values_given_for? lng self.class.translated_attrs.each do |a| begin result = send "#{lng}_#{a}" rescue raise FormTranslation::Errors::InvalidColumnException, 'You need to specify an existing and valid column to store your translations in.' end return true if result.present? end false end