Skip to content

Instantly share code, notes, and snippets.

@starrhorne
Created January 19, 2012 02:42
Show Gist options
  • Save starrhorne/1637348 to your computer and use it in GitHub Desktop.
Save starrhorne/1637348 to your computer and use it in GitHub Desktop.
#
# Here, we query all JobSeekers where any of their "desired
# specializations" match any of the job's "required specializations"
# AND any of their "desired positions" match any of the job's...etc
#
# We also only want JobSeekers who have NOT accepted this job.
#
# And we do a fulltext keyword search too, just for fun.
#
job = Job.find(...)
Sunspot.search(JobSeeker) do
keywords params[:s]
with(:desired_specializations, job.required_specializations)
with(:desired_positions, job.required_positions)
with(:desired_locations, job.required_locations)
without(:accepted_job_ids, job.id)
paginate :page => params[:page]
end.results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment