Is it possible to eager load polymorphic nested associations? How can I include
doctor_profile
's for Recommendation
's and patient_profile
's for Post
's?
I'm able to call Activity.includes(:trackable).last(10)
but not sure how to include the associated models past there. I've tried belongs_to :recommendation, -> { includes :patient_profile, :doctor_profile}
with no luck
class Activity
belongs_to :trackable, polymorphic: true
end
class Recommendation
has_many :activities, as: :trackable
belongs_to :doctor_profile
end
class Post
has_many :activities, as: :trackable
belongs_to :patient_profile
end