Do you use statements like
.. if !name.nil? && !name.empty? .. if params[:name] and !params[:name].empty?
in your code? Using the blank? function of Rails, they can be simplified to
.. if !name.blank? .. if !params[:name].blank?
But we can go even further. Using the present? function, this is equal to
.. if name.present? .. if params[:name].present?
See the documentation for the class object: an object is present if it‘s not blank. An object in Rails is blank if it‘s false, empty, or a whitespace string. That means “”, ” “, nil, [], and {} are blank.
But you can use Object.present? just in Rails 2.2+. For older versions you can use the following to get the same result:
unless name.blank?
unless params[:name].blank?