I may be wrong here, but routes are automatically generated for files in your public directory.
So if this was in your rails project
public/images/cat.jpg
You could literally type " public/images/cat.jpg " and it would appear in the browser. Is there anyway to rake routes and get these asset routes? Or they not actually roots? Do they work differently?
#{RAILS_ROOT}/images/cat.jpg
这样就可以了。
They are not actually routes, they are considered "static assets" and are simply served up as is.
From the Rails asset pipeline documentation :
Any assets under public will be served as static files by the application or web server.
So in the end, there's nothing really special about them; they are merely served up. That's about it.
Also, the URL www.example.com/public/images/cat.jpg
will not work, you'll need to ditch the public
part, so that it appears like www.example.com/images/cat.jpg
, or simply /images/cat.jpg
if this is a link.
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.