Created
May 21, 2013 02:42
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rails.application.engine_name.titleize can probably be substituted here.