Skip to content

Instantly share code, notes, and snippets.

@mattsgarrison
Created May 21, 2013 02:42
Show Gist options
  • Save mattsgarrison/5617187 to your computer and use it in GitHub Desktop.
Save mattsgarrison/5617187 to your computer and use it in GitHub Desktop.
Rails image_tag helper for when an image may or may not exist.
def image_tag_or_default(image_name, options = {})
if RailsApplicationName::Application.assets.find_asset("#{image_name}").nil?
image_tag("default_category.png",options)
else
image_tag("#{image_name}",options)
end
end
@mattsgarrison
Copy link
Author

Rails.application.engine_name.titleize can probably be substituted here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment