Skip to content

Instantly share code, notes, and snippets.

@jeanbaptistebeck
Last active December 10, 2015 09:00
Show Gist options
  • Save jeanbaptistebeck/b82958490382dc6f9dcc to your computer and use it in GitHub Desktop.
Save jeanbaptistebeck/b82958490382dc6f9dcc to your computer and use it in GitHub Desktop.
class Candidate < ActiveRecord::Base
include PgSearch
pg_search_scope :search_by_candidate,
against: {
enterprise: 'A',
last_name: 'B',
first_name: 'C'
},
using: {
tsearch: {
prefix: true
}
}
end
Candidate.create!(enterprise: 'Brand And Celebrities', last_name: 'Bordage', first_name: 'Quentin')
results = Candidate.search_by_candiate("Brand") # [Brand And Celebrities]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment