Rails - How to get the URL of a single image object in a controller?

I tried turning ActionView::Helpers::AssetTagHelperit on and then using the method image_path(), however this gives me sadness:

undefined local variable or method `config' for ActionView::Helpers::AssetTagHelper:Module

Perhaps something simple that I am missing. Any ideas?

+3
source share
1 answer

I found a solution in Barlow here: How can I use image_path inside Rails 3 Controller

view_context.image_path('/path/to/image')

seems to work for me, no need to include helpers in the controller

+10
source

All Articles