Returns path to an image asset. Example:
The src can be supplied as a…
- full path, like "/my_images/image.gif"
- file name, like "rss.gif", that gets expanded to "/images/rss.gif"
- file name without extension, like "logo", that gets expanded to "/images/logo.png"
# File actionpack/lib/action_view/helpers/asset_tag_helper.rb, line 124 def image_path(source) compute_public_path(source, 'images', 'png') end
I would just use the path_to_image. I find that this is what works best. As it says above it can create problems.
Here is my code
def background_path(background) if background path_to_image background.file_name.normal else path_to_image "background_preview.jpg" end end def flavor_path(flavor) if flavor path_to_image flavor.file_name.normal else path_to_image("flavor_preview.jpg") end end
basic but gets the job done and it does not have problem with my pre built paths which are called image_path