Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

do not fetch associations if association id is nil

  • Loading branch information...
commit 624ec3d1f5cfd79bbc2293c98f9b4ddda99ae98d 1 parent 25ac24d
Richard Huang authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/mongoid/criterion/eager_loading.rb
6 lib/mongoid/criterion/eager_loading.rb
View
@@ -50,7 +50,7 @@ def setup_associations_with_ids(documents, reflection, one=true)
ids = []
documents.each do |document|
id_document_map[document.id] = document
- ids << document.id
+ ids << document.id if document.id
end
association_class = reflection.name.singularize.camelize.constantize
@@ -72,11 +72,11 @@ def setup_associations_with_foreign_keys(documents, reflection, one)
foreign_key_value = document.send(foreign_key_name)
if one
id_document_map[foreign_key_value] = document
- ids << foreign_key_value
+ ids << foreign_key_value if foreign_key_value
elsif foreign_key_value
foreign_key_value.each do |fkv|
id_document_map[fkv] = document
- ids << fkv
+ ids << fkv if fkv
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.