Skip to content

Instantly share code, notes, and snippets.

@phil-monroe
Created April 25, 2013 18:03
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 phil-monroe/5461775 to your computer and use it in GitHub Desktop.
Save phil-monroe/5461775 to your computer and use it in GitHub Desktop.
Normalize a query from to just lowercase letters and single spaces
def query
@query ||= params[:query].to_s.tap do |q|
q.strip!
q.downcase!
q.gsub!(/[^a-z\s]/, '')
q.gsub!(/\s+/, ' ')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment