Ruby

Jul
13th
09

Checking variables in Rails

Checking for empty / nill / null values in rails can be a bit confusing and can make your code a bit of a mess checking for nil or empty variables.

Rails provides a utility method “blank” to check if a variable has anything in it.

An object is blank if it‘s false, empty, or a whitespace string. For example, “”, ” “, nil, [], and {} are blank.
(more…)