Sha256: bd9370fe03e72da6f05f69c43f6de659ca51f685e823743df58acd7c733fe7cc
Contents?: true
Size: 654 Bytes
Versions: 8
Compression:
Stored size: 654 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
8 entries across 8 versions & 1 rubygems