lib/bullet/mongoid3.rb in bullet-4.1.4 vs lib/bullet/mongoid3.rb in bullet-4.1.5
- old
+ new
@@ -42,10 +42,12 @@
::Mongoid::Relations::Accessors.class_eval do
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
end
end