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
On
feedbacks = Feedback.map(&:user_id).uniq
User.includes(:jobs => :feedbacks).where.not(:client_id => feedbacks).where(:id => current_user.id)
Try this
On
jobs=Job.find(:all, :select => 'DISTINCT id', :order=>"id asc").map { |n| n.id.to_s })
feedbacks=Feedback.find(:all, :select => 'DISTINCT job_id', :order=>"job_id asc").map { |n| n.job_id.to_s })
jobs_without_feedbacks=jobs-feedbacks
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.
Try this .It will work fine