Activerecord join search

Posted by VP on Stack Overflow See other posts from Stack Overflow or by VP
Published on 2010-04-17T11:22:22Z Indexed on 2010/04/17 11:23 UTC
Read the original article Hit count: 121

Filed under:
|
|

Hi,

i have two models:

class Category 
 has many :jobs
end

class Job
 belongs_to :category
end

So for sure i'm able to do

c = Category.first
c.jobs 

My question is: how can i find just categories that has at least one job?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord