Rails 4 [removed] Having trouble with image paths

前端 未结 2 793
青春惊慌失措
青春惊慌失措 2021-01-17 11:10

I\'m trying to get the background image to change every 6 seconds and it\'s always a 404 error:

For example, the below appears in the JS console

htt         


        
2条回答
  •  再見小時候
    2021-01-17 11:47

    This solved my problem: Section 2.3.1 of guides.rubyonrails.org/asset_pipeline.html

    $('.holder').css("background-image","url(<%= asset_path('tree-rays.jpg') %>)");
    

    Note that tree-rays.jpg is in app/assets/images (Rails 4 Application).

提交回复
热议问题