Created
February 8, 2009 20:56
-
-
Save gaspard/60504 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb | |
index 0fefec1..2f5babe 100644 | |
--- a/activerecord/lib/active_record/associations/association_collection.rb | |
+++ b/activerecord/lib/active_record/associations/association_collection.rb | |
@@ -101,6 +101,7 @@ module ActiveRecord | |
else | |
build_record(attributes) do |record| | |
block.call(record) if block_given? | |
+ record.send(:"#{@owner.class.to_s.underscore}=", @owner) if record.respond_to?(:"#{@owner.class.to_s.underscore}=") | |
set_belongs_to_association_for(record) | |
end | |
end | |
@@ -394,6 +395,9 @@ module ActiveRecord | |
find(:all) | |
end | |
+ records.each do |record| | |
+ record.send(:"#{@owner.class.to_s.underscore}=", @owner) if record.respond_to?(:"#{@owner.class.to_s.underscore}=") | |
+ end | |
@reflection.options[:uniq] ? uniq(records) : records | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment