Has_and_belongs_to_many find with multiple predicates?

Hi,

I have a habtm relationship between ‘Posts’ and ‘Tags’ and am trying to
get a list of Posts that have multiple tags. Something like:

@posts = Posts.find_posts_with_tag_ids[1, 3, 5]

Is this catered for in ActiveRecord or should I write my own SQL
statement?

Thanks,
GiantCranes

I found two posts which deal with this and provide two clever solutions:

http://blog.hasmanythrough.com/articles/2006/06/12/when-associations-arent-enough
http://blog.hasmanythrough.com/articles/2006/06/12/when-associations-arent-enough-part-2

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs