Ruby on rails webpacker can't find images under asset_pack_path

后端 未结 5 1565
野的像风
野的像风 2021-02-06 15:16

I have a problem with including images in my views using Ruby on Rails Webpacker. When i try to insert image in my view using html img tag and asset_pack_path i got an error. My

5条回答
  •  鱼传尺愫
    2021-02-06 15:43

    For accessing images handled by Sprockets, add this to your your_file_name.js.erb file:

    <% helpers = ActionController::Base.helpers %>
    const railsImagePath = "<%= helpers.image_path('your_image.png') %>"
    

提交回复
热议问题