2008-03-21 14:09:03 -04:00
|
|
|
class Club < ActiveRecord::Base
|
2011-01-26 18:00:13 -05:00
|
|
|
has_one :membership
|
2013-06-07 23:59:27 -04:00
|
|
|
has_many :memberships, :inverse_of => false
|
2008-03-21 14:09:03 -04:00
|
|
|
has_many :members, :through => :memberships
|
2008-03-21 22:20:37 -04:00
|
|
|
has_one :sponsor
|
|
|
|
has_one :sponsored_member, :through => :sponsor, :source => :sponsorable, :source_type => "Member"
|
2010-10-14 08:44:32 -04:00
|
|
|
belongs_to :category
|
2008-10-13 13:01:37 -04:00
|
|
|
|
2014-04-10 16:43:59 -04:00
|
|
|
has_many :favourites, -> { where(memberships: { favourite: true }) }, through: :memberships, source: :member
|
2013-11-10 00:28:54 -05:00
|
|
|
|
2008-10-13 13:01:37 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def private_method
|
|
|
|
"I'm sorry sir, this is a *private* club, not a *pirate* club"
|
|
|
|
end
|
2010-10-14 08:44:32 -04:00
|
|
|
end
|
2014-06-17 13:11:22 -04:00
|
|
|
|
|
|
|
class SuperClub < ActiveRecord::Base
|
|
|
|
self.table_name = "clubs"
|
2014-06-19 14:04:39 -04:00
|
|
|
|
|
|
|
has_many :memberships, class_name: 'SuperMembership', foreign_key: 'club_id'
|
|
|
|
has_many :members, through: :memberships
|
|
|
|
end
|