Skip to content

Instantly share code, notes, and snippets.

@antillas21
Created November 13, 2014 20:57
Show Gist options
  • Save antillas21/bd5012fb04199164be86 to your computer and use it in GitHub Desktop.
Save antillas21/bd5012fb04199164be86 to your computer and use it in GitHub Desktop.
Client.search
class Client < ActiveRecord::Base
scope :search, ->(term) {
clients_table = self.arel_table
column = clients_table[:name]
where(column.matches("%#{term}%"))
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment