I'm trying to eager load a nested polymorphic association. I can't seem to find a solution.
Here is my model setup:
class Post
has_many :comments
end
class Comment
belongs_to :ownable, polymorphic: true
end
class User
has_many :comments, as: :ownable
end
And here is what I'm trying to do:
Post.includes(comments: :ownable).to_a
But it's throwing this error:
ActiveRecord::EagerLoadPolymorphicError - Can not eagerly load the polymorphic association :ownable
How can I do eager load this nested polymorphic association?