Commit 570fcd3b by Mai Hoang Thai Ha

fixed n+1 queries in Jobs index

parent 00290967
......@@ -27,7 +27,8 @@ class User < ApplicationRecord
end
def favorite?(job)
favorite_jobs.exists?(job_id: job.id)
@favorite_job_ids ||= Set.new(favorite_jobs.pluck(:job_id))
@favorite_job_ids.include?(job.id)
end
protected
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment