diff options
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/club.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/member.rb | 9 | ||||
-rw-r--r-- | activerecord/test/models/membership.rb | 9 | ||||
-rw-r--r-- | activerecord/test/models/sponsor.rb | 4 |
4 files changed, 28 insertions, 0 deletions
diff --git a/activerecord/test/models/club.rb b/activerecord/test/models/club.rb new file mode 100644 index 0000000000..171445df3e --- /dev/null +++ b/activerecord/test/models/club.rb @@ -0,0 +1,6 @@ +class Club < ActiveRecord::Base + has_many :memberships + has_many :members, :through => :memberships + has_many :current_memberships + has_many :sponsors +end
\ No newline at end of file diff --git a/activerecord/test/models/member.rb b/activerecord/test/models/member.rb new file mode 100644 index 0000000000..688725f200 --- /dev/null +++ b/activerecord/test/models/member.rb @@ -0,0 +1,9 @@ +class Member < ActiveRecord::Base + has_one :current_membership + has_many :memberships + has_many :fellow_members, :through => :club, :source => :members + has_one :club, :through => :current_membership + has_one :favourite_club, :through => :memberships, :conditions => ["memberships.favourite = ?", true], :source => :club + has_one :sponsor, :as => :sponsorable + has_one :sponsor_club, :through => :sponsor +end
\ No newline at end of file diff --git a/activerecord/test/models/membership.rb b/activerecord/test/models/membership.rb new file mode 100644 index 0000000000..905f948c37 --- /dev/null +++ b/activerecord/test/models/membership.rb @@ -0,0 +1,9 @@ +class Membership < ActiveRecord::Base + belongs_to :member + belongs_to :club +end + +class CurrentMembership < Membership + belongs_to :member + belongs_to :club +end diff --git a/activerecord/test/models/sponsor.rb b/activerecord/test/models/sponsor.rb new file mode 100644 index 0000000000..50c2c2d76c --- /dev/null +++ b/activerecord/test/models/sponsor.rb @@ -0,0 +1,4 @@ +class Sponsor < ActiveRecord::Base + belongs_to :sponsor_club, :class_name => "Club", :foreign_key => "club_id" + belongs_to :sponsorable, :polymorphic => true +end
\ No newline at end of file |