简体   繁体   中英

how to have assets other than js and css files in rails

I have some object files which I want to have them in my JS codes I put them under app/assets/3d-models and when I try to get a link to it I use:

<%= asset_path("3d-models/splits2/xxx.obj") %>

But the output is /3d-models/splits2/xxx.obj which obviously the 404 NOT FOUND is the result(ie the asset not found, the wrong link!)

Question:

How can I get an access link to a file other than common files used in rails' assets?

You can have different assets. Just place them into assets folder and link to them correctly.

Rails are using assets pipeline . This is a concept, which provides a better way to serve some static files to a website. In Rails it is implemented by Sprockets gem . Please read more here .

You can also have other static files directly in public folder and link to those files anywhere from your app. This will not be included in assets pipeline.

If you use assets_path helper method, then there is a fingerprint added to a file so the URL to the file is different then.

Please check this section .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM