blank?
In Rails, when checking a value from params to see if it’s empty, don’t use
params[:a_value].empty?
because if params[:a_value] isn’t given (nil), it will fail with a NoMethodError. Use this instead:
params[:a_value].blank?
blank? is a Rails core-extension that lives in Object, so everything has the blank? method.
0 comments