Skip to content

Instantly share code, notes, and snippets.

@knwang
Created October 8, 2011 19:02
Show Gist options
  • Save knwang/1272707 to your computer and use it in GitHub Desktop.
Save knwang/1272707 to your computer and use it in GitHub Desktop.
Proofing_oven: candidate model with search
class Candidate < ActiveRecord::Base
before_save :denormalize_name
def self.search(term)
term.blank? ? Candidate.all : where("full_name like ?", "%#{term}%")
end
private
def denormalize_name
self.full_name = [first_name, last_name].join(' ')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment