Has_and_belongs_to_many find

Say I have a post model that has_and_belongs_to_many :categories, and a
category model that has_and_belongs_to_many :posts. So I have a
categories_posts table to do the join. That’s all find and dandy.
However I want to be able to find all the posts that belong to a
specific category.

I tried Post.find_by_category(:id) but that doesn’t work.

Does anyone have any insight?

Thanks in advance.

Hi Micheal

Try it the other way around

Category.find( some id).posts

How about…

Category.find(:id).posts

~ Ben

Ben R. wrote:

How about…

Category.find(:id).posts

~ Ben

Sweet thanks guys!