I'm using image_path into my controller:
class ArchivesController < ApplicationController
include ActionView::Helpers::AssetUrlHelper
def create
@archive = Archive.new(file: params[:file])
render json: {ico: image_path('docs/pdf.png')}
end
end
But my return is {ico: '/images/docs/pdf.png'}.
When I'm use image_path('docs/pdf.png') in my views, the url is '/docs/pdf.png' and works.
Why in my controller the url is different?
Answer from my comment:
You can use view_context.image_path 'pdf.png' without including the helper library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With