Skip to content

Instantly share code, notes, and snippets.

@peteroome
Created April 24, 2013 10:09
Show Gist options
  • Save peteroome/5451096 to your computer and use it in GitHub Desktop.
Save peteroome/5451096 to your computer and use it in GitHub Desktop.
Searching. Building up a query
def self.search(params)
scope = scoped({})
scope = scope.scoped :where => ['title_id = ?', params[:title_id] ] unless params[:title_id].blank?
scope = scope.scoped :where => ['upper(first_name) like upper(?)', params[:first_name] ] unless params[:manufacturers].blank?
scope
end
@results = Student.search(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment