diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-28 01:33:20 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-28 01:33:20 +0530 |
commit | 51a1d5a6708726ae03deb5869f36e7d5cca22a6e (patch) | |
tree | 30bc57056a5f730ff89d41e715c8587fd916775f /activerecord/lib/active_record/relation.rb | |
parent | a8b10a2a8d6f8d861453803264b9ef1b0cadbc6b (diff) | |
download | rails-51a1d5a6708726ae03deb5869f36e7d5cca22a6e.tar.gz rails-51a1d5a6708726ae03deb5869f36e7d5cca22a6e.tar.bz2 rails-51a1d5a6708726ae03deb5869f36e7d5cca22a6e.zip |
Handle preloads and eager loads when merging relations
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 967e429fc3..d0f6c5a63f 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -2,7 +2,7 @@ module ActiveRecord class Relation delegate :to_sql, :to => :relation delegate :length, :collect, :find, :map, :each, :to => :to_a - attr_reader :relation, :klass + attr_reader :relation, :klass, :associations_to_preload, :eager_load_associations def initialize(klass, relation, readonly = false, preload = [], eager_load = []) @klass, @relation = klass, relation @@ -19,7 +19,9 @@ module ActiveRecord where(r.send(:where_clause)). limit(r.taken). offset(r.skipped). - select(r.send(:select_clauses).join(', ')) + select(r.send(:select_clauses).join(', ')). + eager_load(r.eager_load_associations). + preload(r.associations_to_preload) end alias :& :merge |