Start Using Squish in Rails


Just a quick tip - how many times have you found yourself cleaning up strings (maybe user input?) by doing things like this:

string = string.gsub(/\s+/, " ").strip

and the like? You want to replace consecutive whitespace with single whitespace and remove beginning and trailing whitespace.

If you’re using rails, try squish - squish. Note that squish removes newlines, so it may not be appropriate for every scenario, but it’s a generally very useful function.

I'm looking for better ways to build software businesses. Find out if I find something.