Module: ActiveRecord::Acts::MuckInvite::ClassMethods

Defined in:
lib/active_record/acts/muck_invite.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_muck_invite(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record/acts/muck_invite.rb', line 10

def acts_as_muck_invite(options = {})
  belongs_to :invitee
  belongs_to :inviter, :polymorphic => true
  # User and inviter might be the same.  For example, if a user invites their friends then user == inviter.  
  # However if inviter is something else for example an Event then having a user field let's us quickly
  # discover who created the invite.  (Used by who_invited?)
  belongs_to :user
  
  named_scope :by_newest, :order => "created_at DESC"
  named_scope :by_oldest, :order => "created_at ASC"
  named_scope :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } }


  include ActiveRecord::Acts::MuckInvite::InstanceMethods
  extend ActiveRecord::Acts::MuckInvite::SingletonMethods
  
end