I am trying to make a MissingImage
class like this:
class MissingImage
include ActionView::Helpers::AssetUrlHelper
def src format
return asset_path('layout/missing_image.png')
end
end
To use like this in the model:
def main_image
images.find(&:ismain) || images.first || MissingImage.new
end
The problem is - asset_path
when used like this simply returns the string without any connection to the asset pipeline.
Suggestions?
UPDATE
After pocking around I have refactored MissingImage
somewhat, but it still doesn't generate signed asset path in production:
class MissingImage
def src format
return ActionController::Base.helpers.asset_path('layout/missing_image.png')
end
end
The path returned is /assets/layout/missing_image.png