I have three models, JobPosting, Job, and Organization. The relations are below:
- An Organization has many Jobs.
- A Job belongs to an Organization and has many JobPostings.
- A JobPosting belongs to a Job.
A Job has an attribute called job_type
, and I am able to find all of the JobPostings that are related to a Job with a specific job_type
using the query:
JobPosting.joins(:job).where(jobs: { :job_type => 'volunteer' })
But what I am struggling with is doing the same kind of thing but with an Organization attribute. A Organization has a attribute called department
, how can I query for the JobPosting's that relate to an organization through a Job that has a specific department. The reason I am having trouble is because Organizations are essentially two levels up, whereas Job's are only one.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire