diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-19 01:02:21 +0000 |
---|---|---|
committer | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-26 18:25:55 +0000 |
commit | 5cebe69e74d411c3c9e5f6ab9d4b2b16ee36177c (patch) | |
tree | 7e30226bcda0e5f9292b71927a32d5c15133e391 /activerecord/test/models | |
parent | eb457ceee13779ade67e1bdebd2919d476148277 (diff) | |
download | rails-5cebe69e74d411c3c9e5f6ab9d4b2b16ee36177c.tar.gz rails-5cebe69e74d411c3c9e5f6ab9d4b2b16ee36177c.tar.bz2 rails-5cebe69e74d411c3c9e5f6ab9d4b2b16ee36177c.zip |
Preload uses exclusive scope [#643 state:resolved]
With self referential associations, the scope for the the top level should not affect fetching of associations, for example
when doing
Person.male.find :all, :include => :friends
we should load all of the friends for each male, not just the male friends.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/person.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb index 430d0b38f7..ec2f684a6e 100644 --- a/activerecord/test/models/person.rb +++ b/activerecord/test/models/person.rb @@ -7,4 +7,10 @@ class Person < ActiveRecord::Base has_many :jobs, :through => :references has_one :favourite_reference, :class_name => 'Reference', :conditions => ['favourite=?', true] has_many :posts_with_comments_sorted_by_comment_id, :through => :readers, :source => :post, :include => :comments, :order => 'comments.id' + + belongs_to :primary_contact, :class_name => 'Person' + has_many :agents, :class_name => 'Person', :foreign_key => 'primary_contact_id' + + named_scope :males, :conditions => { :gender => 'M' } + named_scope :females, :conditions => { :gender => 'F' } end |