1
0
Fork 0
find-us-lunch/app/models/friendship.rb

14 lines
327 B
Ruby
Raw Normal View History

2014-10-15 13:17:36 -04:00
class Friendship < ActiveRecord::Base
belongs_to :user
belongs_to :friend, class_name: 'User'
2014-10-27 12:25:36 -04:00
validates_uniqueness_of :friend_id, :scope => :user_id
2014-10-27 12:27:32 -04:00
validate :disallow_self_reference
def disallow_self_reference
if friend_id == user_id
errors.add(:friend_id, 'cannot refer back to self')
end
end
2014-10-15 13:17:36 -04:00
end