blank?

December 9th, 2005

Just a little Rails think but i use it so often nowadays its worth mentioning.

using the .blank? method is another way of saying .nil? or .empty?

for instance


unless post.name.nil? or post.name.empty?

you can use

unless post.name.blank?

its a neat shortcut and not part of Ruby, its in the core extensions as part of Rails. There are many good gems in there.

Sorry, comments are closed for this article.