diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-11 08:55:36 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-11 08:56:01 +0100 |
commit | 1dd90f8f12d1904ee3db37f9390df3246bb2712b (patch) | |
tree | af878256f943714b18e07be9f1238ddd3fe47b71 /activerecord/test/models | |
parent | aa1fc1c88cb58b6387cb7a8560aac78ef56fa024 (diff) | |
download | rails-1dd90f8f12d1904ee3db37f9390df3246bb2712b.tar.gz rails-1dd90f8f12d1904ee3db37f9390df3246bb2712b.tar.bz2 rails-1dd90f8f12d1904ee3db37f9390df3246bb2712b.zip |
Don't use select() values from the join model of a through association. Fixes #508.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/member.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/membership.rb | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/models/member.rb b/activerecord/test/models/member.rb index 991e0e051f..11a0f4ff63 100644 --- a/activerecord/test/models/member.rb +++ b/activerecord/test/models/member.rb @@ -1,8 +1,10 @@ class Member < ActiveRecord::Base has_one :current_membership + has_one :selected_membership has_one :membership has_many :fellow_members, :through => :club, :source => :members has_one :club, :through => :current_membership + has_one :selected_club, :through => :selected_membership, :source => :club has_one :favourite_club, :through => :membership, :conditions => ["memberships.favourite = ?", true], :source => :club has_one :hairy_club, :through => :membership, :conditions => {:clubs => {:name => "Moustache and Eyebrow Fancier Club"}}, :source => :club has_one :sponsor, :as => :sponsorable diff --git a/activerecord/test/models/membership.rb b/activerecord/test/models/membership.rb index 905f948c37..bcbb7e42c5 100644 --- a/activerecord/test/models/membership.rb +++ b/activerecord/test/models/membership.rb @@ -7,3 +7,9 @@ class CurrentMembership < Membership belongs_to :member belongs_to :club end + +class SelectedMembership < Membership + def self.default_scope + select("'1' as foo") + end +end |