Module: FormTranslation::ForModel
- Defined in:
- lib/form_translation/for_model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
24 25 26 |
# File 'lib/form_translation/for_model.rb', line 24 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#translate!(language = I18n.locale) ⇒ Object
16 17 18 19 20 21 22 |
# 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) ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 14 |
# 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 |