Permalink
Browse files

Dont reload on empty associations

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1231 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Apr 19, 2005
1 parent 77af61b commit 3140e37d18c66527a80a153727a7ea972b80506a
Showing with 4 additions and 2 deletions.
  1. +4 −2 activerecord/lib/active_record/associations.rb
@@ -702,16 +702,18 @@ def find_with_associations(options = {})
record = records[id]
reflections.each do |reflection|
- next unless row[primary_key_table[reflection.table_name]]
-
case reflection.macro
when :has_many, :has_and_belongs_to_many
collection = record.send(reflection.name)
collection.loaded
+ next unless row[primary_key_table[reflection.table_name]]
+
association = reflection.klass.send(:instantiate, extract_record(schema_abbreviations, reflection.table_name, row))
collection.target.push(association) unless collection.target.include?(association)
when :has_one, :belongs_to
+ next unless row[primary_key_table[reflection.table_name]]
+
record.send(
"#{reflection.name}=",
reflection.klass.send(:instantiate, extract_record(schema_abbreviations, reflection.table_name, row))

0 comments on commit 3140e37

Please sign in to comment.