Sha256: 03418be2eecd3b729d35ddb1b809dfbf27c67877d3341fc02e02355e84060ad6
Contents?: true
Size: 652 Bytes
Versions: 5
Compression:
Stored size: 652 Bytes
Contents
module SimpleModelTranslations module Validations class TranslationsValidator < ActiveModel::Validator def validate(record) locales = options[:locales] locales = [locales] unless locales.respond_to?(:each) locales.each do |locale| unless record.find_translation_by_locale(locale) record.errors.add(:translations, "miss #{locale} translation") end end end end def validate_translations(*locales) validates_with TranslationsValidator, :locales => locales end def validate_translation(locale) validate_translations locale end end end
Version data entries
5 entries across 5 versions & 1 rubygems