Take the 2-minute tour ×

Let's say I have:

class Post
  has_many :tags, :through => :taggings
  has_many :taggings

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I think you can use includes on the association proxy as you would with the model class:

taggings = post.taggings.includes(:tag)
share|improve this answer
Thanks, that's the syntax I was after. –  mahemoff Dec 23 '11 at 3:55
add comment

Your Answer


