Class: TranslatedAttr::Validators::TranslationsPresenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- TranslatedAttr::Validators::TranslationsPresenceValidator
- Defined in:
- lib/translated_attr/active_record_extensions.rb
Overview
Presence Validators
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/translated_attr/active_record_extensions.rb', line 6 def validate_each(record, attribute, value) translations_present = record.translations.map{ |t| t.locale.try(:to_sym) } I18n.available_locales.each do |locale| unless translations_present.include?(locale) record.errors[attribute] << I18n.t('translated_attr.errors.translations_presence', :attr => I18n.t("activerecord.attributes.#{record.class.name.downcase}.name"), :lang => locale) end end end |