diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 19:56:53 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 19:56:53 -0700 |
commit | e66bf6f5e3085014976ff8fa3981813b77510b69 (patch) | |
tree | 8a268ef4207cefd912b4d272bf6c10ab47439161 /activerecord | |
parent | 9b81ae69692300721ea89177d230f8eaa4ea9556 (diff) | |
download | rails-e66bf6f5e3085014976ff8fa3981813b77510b69.tar.gz rails-e66bf6f5e3085014976ff8fa3981813b77510b69.tar.bz2 rails-e66bf6f5e3085014976ff8fa3981813b77510b69.zip |
remove more codes
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index f1aa87ef1f..715c868598 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -296,9 +296,10 @@ module ActiveRecord options = reflection.options primary_key_name = reflection.primary_key_name + klasses_and_ids = {} + if options[:polymorphic] polymorph_type = options[:foreign_type] - klasses_and_ids = {} # Construct a mapping from klass to a list of ids to load and a mapping of those ids back # to their parent_records @@ -307,23 +308,20 @@ module ActiveRecord klass_id = record.send(primary_key_name) if klass_id id_map = klasses_and_ids[klass] ||= {} - id_list_for_klass_id = (id_map[klass_id.to_s] ||= []) - id_list_for_klass_id << record + (id_map[klass_id.to_s] ||= []) << record end end end - klasses_and_ids = klasses_and_ids.to_a else id_map = {} records.each do |record| key = record.send(primary_key_name) (id_map[key.to_s] ||= []) << record if key end - klasses_and_ids = [[reflection.klass.name, id_map]] + klasses_and_ids[reflection.klass.name] = id_map unless id_map.empty? end klasses_and_ids.each do |klass_name, id_map| - next if id_map.empty? klass = klass_name.constantize table_name = klass.quoted_table_name |