no route matches for assets/images in Rails

前端 未结 2 1831
逝去的感伤
逝去的感伤 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

    0 讨论(0)
  • 2021-01-05 07:01

    The lack of a fingerprint in the file request suggests that you are running this in development. I am also going to guess that this is an app upgraded from an older version of Rails.

    Any images need to be in the folder /assets/images for the pipeline to work.

    Also, you do not need to precompile when in development mode.

    Delete the public/assets folder, delete the folder tmp/cache/assets, and restart your server.

    If this images are in the correct location, it should work.

    0 讨论(0)
提交回复
热议问题