Skip to content

Instantly share code, notes, and snippets.

@knwang
Created October 8, 2011 20:34
Show Gist options
  • Save knwang/1272833 to your computer and use it in GitHub Desktop.
Save knwang/1272833 to your computer and use it in GitHub Desktop.
Proofing_oven: Candidate Model refactored
class Candidate < ActiveRecord::Base
scope :search, ->(term) { term.blank? ? {} : where("full_name like ?", "%#{term}%") }
before_save :denormalize_name
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