Module: HasFriends::ClassMethods

Defined in:
lib/has_friends.rb

Instance Method Summary collapse

Instance Method Details

#has_friendsObject



8
9
10
11
12
13
14
15
16
# File 'lib/has_friends.rb', line 8

def has_friends
  include HasFriends::InstanceMethods

  has_many :friendships
  has_many :friends, :through => :friendships, :source => :friend, :conditions => "friendships.status = 'accepted'"
  has_many :friends_pending, :through => :friendships, :source => :friend, :conditions => "friendships.status = 'pending'"

  before_destroy :destroy_all_friendships
end