Skip to content

Commit

Permalink
Merge pull request #341 from naw/fix-association-call-tracking
Browse files Browse the repository at this point in the history
Fix Rails 5 false positive for intermediate (through) associations
  • Loading branch information
flyerhzm committed May 28, 2017
2 parents cd88b60 + bcb7b69 commit 3c93d45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bullet/active_record5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def include?(object)

::ActiveRecord::Associations::SingularAssociation.prepend(Module.new {
# call has_one and belongs_to associations
def reader(force_reload = false)
result = force_reload ? force_reload_reader : super()
def target
result = super()
if Bullet.start?
if owner.class.name !~ /^HABTM_/ && !@inversed
Bullet::Detector::NPlusOneQuery.call_association(owner, reflection.name)
Expand Down

0 comments on commit 3c93d45

Please sign in to comment.