Created
October 8, 2011 19:02
-
-
Save knwang/1272707 to your computer and use it in GitHub Desktop.
Proofing_oven: candidate model with search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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