1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/models/club.rb
Rafael Mendonça França a7a180bd81 Merge pull request #12829 from iantropov/issue_insert_via_hmt_scope_3548
Fix insertion of records for hmt association with scope

Conflicts:
	activerecord/CHANGELOG.md
2014-04-10 17:44:32 -03:00

16 lines
511 B
Ruby

class Club < ActiveRecord::Base
has_one :membership
has_many :memberships, :inverse_of => false
has_many :members, :through => :memberships
has_one :sponsor
has_one :sponsored_member, :through => :sponsor, :source => :sponsorable, :source_type => "Member"
belongs_to :category
has_many :favourites, -> { where(memberships: { favourite: true }) }, through: :memberships, source: :member
private
def private_method
"I'm sorry sir, this is a *private* club, not a *pirate* club"
end
end