Chris Richards wrote:
I always do this when checking to see if a parameter exists and that it is not blank:
if params[:name] and !params[:name].empty? ... end
Is there a better way? a simpler way.
Rails defines an method 'blank?' that will work for any object, including nil. It returns true when it's called on a nil object, or an empty string, hash or array. So you can use
if !params[:name].blank?
Chris