diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2009-05-07 01:03:52 +0100 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-05-10 12:50:02 +1200 |
commit | ef6f22ab2aadf619c993527150490d6d48a719c6 (patch) | |
tree | db8d5077c0ec15c8a9ce77b7f524c7158a668b33 /activerecord/lib/active_record | |
parent | 8ee0c598dbe3f9fd133e85c69c6e43f62056646c (diff) | |
download | rails-ef6f22ab2aadf619c993527150490d6d48a719c6.tar.gz rails-ef6f22ab2aadf619c993527150490d6d48a719c6.tar.bz2 rails-ef6f22ab2aadf619c993527150490d6d48a719c6.zip |
honour inverse_of when preloading associations
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index e4ab69aa1b..967fff4d6f 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -126,6 +126,7 @@ module ActiveRecord association_proxy = parent_record.send(reflection_name) association_proxy.loaded association_proxy.target.push(*[associated_record].flatten) + association_proxy.__send__(:set_inverse_instance, associated_record, parent_record) end end @@ -152,7 +153,8 @@ module ActiveRecord seen_keys[associated_record[key].to_s] = true mapped_records = id_to_record_map[associated_record[key].to_s] mapped_records.each do |mapped_record| - mapped_record.send("set_#{reflection_name}_target", associated_record) + association_proxy = mapped_record.send("set_#{reflection_name}_target", associated_record) + association_proxy.__send__(:set_inverse_instance, associated_record, mapped_record) end end end |