Class: Elabs::AssociatedAuthorValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/validators/elabs/associated_author_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



3
4
5
6
7
8
9
# File 'app/validators/elabs/associated_author_validator.rb', line 3

def validate(record)
  options[:relations].each do |association|
    record.send(association.pluralize).each do |element|
      record.errors[:base] << format(_('This %<model>s is not yours'), model: association) if element.user_id != record.user_id
    end
  end
end