A route to serve static assets (like .jpgs, etc?)

前端 未结 5 1267
后悔当初
后悔当初 2021-02-02 16:19

I\'ve worked my way through a number of interesting routing problems - turning a request URL into a hash, etc., but just out of curiosity, is there a way to tell the routing sys

5条回答
  •  礼貌的吻别
    2021-02-02 16:43

    If you put the "images" directory into the "public" folder of the Rails app (for example: /public/images/) then you shouldn't have any problems with MIME types unless your web server is configured wrongly.

    According to your examples, you want the images dir in the root of the app. I don't think there is a way though Rails to make those images visible, but if you really wanted to you could use mod_rewrite to make it work. Once again, it would be up to the web server to make sure the images had the correct MIME type.

提交回复
热议问题