如何在Nginx上使用asset_path和文件

时间:2013-11-08 22:26:41

标签: ruby-on-rails asset-pipeline

我的理解是,在生产中,类似下面的内容将产生一个带有哈希后跟foo.img的路径。

<%= asset_path 'foo.img' %>

但是如果我把文件foo.img放在Rails应用程序中而不是在Nginx反向代理中(因此没有任何前缀哈希),那么我想如何引用正确的路径?如果asset_path将生成带有哈希前缀的路径,那么如何让它引用正确的路径以便图像请求能够访问Nginx的foo.img

我想为生产预编译并将其复制到nginx知道的目录中吗?

1 个答案:

答案 0 :(得分:0)

您可以通过config.assets.prefix设置网址路径,并使用config.assets.paths配置资源查找位置。

来自configuring assets的指南:

config.assets.paths contains the paths which are used to look for assets. Appending paths to this configuration option will cause those paths to be used in the search for assets.

config.assets.prefix defines the prefix where assets are served from. Defaults to /assets.