Skip to content

Commit

Permalink
Only include associations when the relevant rows have content
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1079 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Apr 3, 2005
1 parent 430ca4d commit 4f6c943
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations.rb
Expand Up @@ -652,7 +652,7 @@ def construct_finder_sql_with_included_associations(reflections)

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
Expand Down

0 comments on commit 4f6c943

Please sign in to comment.