I get the error Cannot eagerly load the polymorphic association :messageable_fromuser
online = Message.all.joins(:messageable_fromuser)
I tried
online = Message.all.includes(:messageable_fromuser)
But it doesn't include the joined table in the result. I see two queries in my log when using includes. I don't know why people recommend using includes to eager load. How is two queries going to join anything?
Using preload should solve the error:
online = Message.preload(:messageable_fromuser)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With