I am generating image tags from within one of my models and I can't get Rails to create working URLs in both development and production mode simultaneously. I started out with this in one of my models:
def traffic_light_icon(size=15)
image_tag "/assets/#{size}/#{traffic_colour}.png"
end
(I'm getting access to image_tag with include ActionView::Helpers::AssetTagHelper
.)
This worked fine in development, but in production, the link was not automatically updated with the appropriate hash to take an image from the asset pipeline. If I try to use the form
image_tag "#{size}/#{traffic_colour}.png"
instead (as various sources suggest), then it doesn't even work in development -- I get a Routing Error (No route matches [GET] /image/15/amber.png).
What am I doing wrong?