Permalink
Browse files

skip call_association in relation is embed instead of reference

  • Loading branch information...
1 parent 258028a commit 3b4f4665ae1a48ed970724f13308dd8187d62bb0 @flyerhzm committed Jul 14, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −1 lib/bullet/mongoid24.rb
  2. +3 −1 lib/bullet/mongoid3.rb
@@ -45,7 +45,9 @@ def eager_load(docs)
alias_method :origin_set_relation, :set_relation
def set_relation(name, relation)
- Bullet::Detector::NPlusOneQuery.call_association(self, name)
+ if relation && relation.metadata.macro !~ /embed/
+ Bullet::Detector::NPlusOneQuery.call_association(self, name)
+ end
origin_set_relation(name, relation)
end
end
@@ -44,7 +44,9 @@ def eager_load(docs)
alias_method :origin_set_relation, :set_relation
def set_relation(name, relation)
- Bullet::Detector::NPlusOneQuery.call_association(self, name)
+ if relation && relation.metadata.macro !~ /embed/
+ Bullet::Detector::NPlusOneQuery.call_association(self, name)
+ end
origin_set_relation(name, relation)
end
end

0 comments on commit 3b4f466

Please sign in to comment.