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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user