Let's say I have:
class Post
has_many :tags, :through => :taggings
has_many :taggings
end
Notice there's no :include. Now say I want to retrieve all taggings and tags in the same query. How could I do that?
I'm looking for something like:
taggings = post.taggings(:include => tags) # doesn't work
I could make a custom query or add a third association to Post with an :include, but neither feels right.
I think you can use includes on the association proxy as you would with the model class:
taggings = post.taggings.includes(:tag)
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