Created
April 25, 2013 18:03
-
-
Save phil-monroe/5461775 to your computer and use it in GitHub Desktop.
Normalize a query from to just lowercase letters and single spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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