diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-05-07 21:35:41 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-11 20:01:14 +0100 |
commit | 3f0dccbbc7c98938349650033ff9a41a814d300d (patch) | |
tree | c19906d9c79d3023c7769103584dd8572c5e5870 /activerecord/lib/active_record | |
parent | 8f2f88f128104355b100487008800aeb369ca425 (diff) | |
download | rails-3f0dccbbc7c98938349650033ff9a41a814d300d.tar.gz rails-3f0dccbbc7c98938349650033ff9a41a814d300d.tar.bz2 rails-3f0dccbbc7c98938349650033ff9a41a814d300d.zip |
Ensure hm:t preloading honours reflection options. [#137 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index da4ebdef51..660d7647c7 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -143,7 +143,8 @@ module ActiveRecord through_primary_key = through_reflection.primary_key_name unless through_records.empty? source = reflection.source_reflection.name - through_records.first.class.preload_associations(through_records, source) + #add conditions from reflection! + through_records.first.class.preload_associations(through_records, source, reflection.options) through_records.each do |through_record| add_preloaded_records_to_collection(id_to_record_map[through_record[through_primary_key].to_s], reflection.name, through_record.send(source)) @@ -251,12 +252,12 @@ module ActiveRecord conditions << append_conditions(options, preload_options) reflection.klass.find(:all, - :select => (options[:select] || "#{table_name}.*"), - :include => options[:include], + :select => (preload_options[:select] || options[:select] || "#{table_name}.*"), + :include => preload_options[:include] || options[:include], :conditions => [conditions, ids], :joins => options[:joins], - :group => options[:group], - :order => options[:order]) + :group => preload_options[:group] || options[:group], + :order => preload_options[:order] || options[:order]) end |