From 4f6c943b05ea537be515ae6d70f8986191ef7e30 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Apr 2005 12:04:57 +0000 Subject: Only include associations when the relevant rows have content git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1079 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/associations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index fa3c28f7d4..ba6a0ab89b 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -652,7 +652,7 @@ module ActiveRecord def extract_association_for_record(record, rows, reflection) association = rows.collect do |row| - if row["#{table_name}__#{primary_key}"] == record.id.to_s + if row["#{table_name}__#{primary_key}"] == record.id.to_s && !row["#{reflection.klass.table_name}__#{reflection.klass.primary_key}"].nil? reflection.klass.send(:instantiate, extract_record(reflection.klass.table_name, row)) end end -- cgit v1.2.3