Skip to content

Instantly share code, notes, and snippets.

@jongilbraith
Created February 19, 2010 10:43
Show Gist options
  • Save jongilbraith/308631 to your computer and use it in GitHub Desktop.
Save jongilbraith/308631 to your computer and use it in GitHub Desktop.
def each_if_present(collection, options = {}, &block)
options[:empty_message] ||= "Nothing to display"
if collection.present?
collection.each(&block)
else
concat content_tag(:div, options[:empty_message], :class => :no_content)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment