Skip to content

Instantly share code, notes, and snippets.

@BenEddy
Created August 27, 2013 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenEddy/6348301 to your computer and use it in GitHub Desktop.
Save BenEddy/6348301 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name
def self.name_matching(name)
where("lower(first_name) LIKE lower(:name)
OR lower(last_name) LIKE lower(:name)", name: name + "%")
end
def self.email_matching(email)
where("lower(email) LIKE lower(?)", email + "%")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment