Lead.includes(:contacts).where("contacts.primary" =>true)
2. Person.includes(notes: [:grades]).where(notes: {important: true, grades: {important: true})
3.
class Person < ActiveRecord::Base
has_many :notes
has_many :important_notes, -> { where(important: true) }, class_name: "Note"
end
Person.preload(:important_notes)
4.
Person.eager_load(:notes)
No comments:
Post a Comment