Validate both the model and its translations

This way we guarantee there will be at least one translation for a model
and we keep compatibility with the rest of the application, which
ideally isn't aware of globalize.
This commit is contained in:
Javi Martín
2018-10-11 02:40:09 +02:00
parent 2ab49a1832
commit 863b326142
11 changed files with 20 additions and 42 deletions

View File

@@ -5,11 +5,8 @@ class AdminNotification < ActiveRecord::Base
translates :body, touch: true
include Globalizable
translation_class.instance_eval do
validates :title, presence: true
validates :body, presence: true
end
validates_translation :title, presence: true
validates_translation :body, presence: true
validates :segment_recipient, presence: true
validate :validate_segment_recipient