I have Job and Feedback models.
They are associated like this:
Job has_many :feedbacks
Feedback belongs_to :job
I'm trying to make a query to get jobs which have NO feedbacks with feedback.user_id == job.client_id
I have Job and Feedback models.
They are associated like this:
Job has_many :feedbacks
Feedback belongs_to :job
I'm trying to make a query to get jobs which have NO feedbacks with feedback.user_id == job.client_id
This uses two queries, but the pluck
should be relatively light.
Job.includes(:feedbacks)
.where(feedbacks: {id: nil})
.where.not(client_id: Feedback.pluck(:user_id))
ok. then try this. it might work good in your case. jobs_without_feedbacks will be the array of ids of the job with no feedback.