Ask A Question

Notifications

You’re not receiving notifications from this thread.

Eager Loading on Rails 5.1

Pardha asked in Rails

Hi all,

Seems that the eager loding doen't work in my application.  Please let me  know whether  I need to enable or configure anything.  Here is th code for association mappings. 
 class Event < ApplicationRecord
                has_many :receipts, dependent: :destroy
                has_many :receipt_happenings, through: :receipts
                has_many :receipt_amounts, through: :receipt_happenings, source: :paper_money
    end

I could see that the query is running while Iteraing the result set coming from

Event.includes(receipts: {receipt_happenings: :paper_money})

Reply

What's the issue you're facing? Is that you're noticing N+1 queries when you loop over events? Or something else?

Reply

Yes Jeffrey . I am noticing N+1 queries when loop over events.

Reply

Is this solved ?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.