add relation validates

This commit is contained in:
Alexander Machehin 2014-11-17 15:05:45 +05:00
parent 855eab3113
commit 9406ac6681
1 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,12 @@ class Relation < ActiveRecord::Base
validates :role, inclusion: { in: ROLES }
validates :target,
presence: true
validates :actor,
presence: true
# validate { errors.add(:actor, :taken) if Relation.where(actor_type: self.actor_type, actor_id: self.actor_id).present? }
before_validation :add_default_role