no route matches for assets/images in Rails

前端 未结 2 1830
逝去的感伤
逝去的感伤 2021-01-05 06:30

Working on rails, images are not visible and giving error.

Started GET \"/assets/home.png\" for 127.0.0.1 at 2012-06-19 12:23:24 +0530
Served asset /home.png         


        
2条回答
  •  长发绾君心
    2021-01-05 06:58

    Actually you cannot reference your image with /assets/home.png path. It will work in development mode, but in production all of your assets have a fingerprint in their filename (read this http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark)

    That's why, in assets-pipeline enabled applications you need to reference all of your assets using helper methods. Read this doc to learn about the different helpers available in Ruby, JS and Sass files: http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets

提交回复
热议问题