[#345] temporaly add attribute accessible to relation

This commit is contained in:
Alexander Machehin 2014-03-15 00:16:20 +06:00
parent 58c057b5c2
commit 6573bb0d9e
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,8 @@ class Relation < ActiveRecord::Base
# validate { errors.add(:actor, :taken) if Relation.where(actor_type: self.actor_type, actor_id: self.actor_id).present? }
before_validation :add_default_role
attr_accessible :actor_id, :actor_type, :target_id, :target_type, :role
scope :by_user_through_groups, ->(u) {
where("actor_type = 'User' AND actor_id = ? OR actor_type = 'Group' AND actor_id IN (?)", u.id, u.group_ids)
}