生产中的 Rails 3 资产路由问题
目前,我的资产位于 app/assets 目录中的 jquery.rest.js 和 jquery-ui-1.8.11.custom.min.js 文件中,但我在生产日志中不断收到以下错误。
Started GET "/assets/jquery.rest-f1490ffc30dcefe21715ae360de2bead.js" for 24.141.74.123 at 2011-12-20 18:40:50 -0500
Served asset /jquery.rest-f1490ffc30dcefe21715ae360de2bead.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/jquery.rest-f1490ffc30dcefe21715ae360de2bead.js"):
Started GET "/assets/jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js" for 24.141.74.123 at 2011-12-20 18:40:50 -0500
Served asset /jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js"):
我的应用程序正在开发中,我不知道为什么在 javascript 文件名称的末尾附加长字符串,即 -707e06de7fe351e6e77e419988c20fd6
for jquery-ui-1.8.11.custom.min生产中的 .js
I currently have my assets in the jquery.rest.js and jquery-ui-1.8.11.custom.min.js files in my app/assets directory, yet i keep getting the following errors in my production logs.
Started GET "/assets/jquery.rest-f1490ffc30dcefe21715ae360de2bead.js" for 24.141.74.123 at 2011-12-20 18:40:50 -0500
Served asset /jquery.rest-f1490ffc30dcefe21715ae360de2bead.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/jquery.rest-f1490ffc30dcefe21715ae360de2bead.js"):
Started GET "/assets/jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js" for 24.141.74.123 at 2011-12-20 18:40:50 -0500
Served asset /jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js - 404 Not Found (3ms)
ActionController::RoutingError (No route matches [GET] "/assets/jquery-ui-1.8.11.custom.min-707e06de7fe351e6e77e419988c20fd6.js"):
My app works in development, i dont know why the long string is appended at the end of of the name of javascript files ie -707e06de7fe351e6e77e419988c20fd6
for jquery-ui-1.8.11.custom.min.js
in production
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该字符串称为指纹。 Rails 在生产模式中添加这些,以允许在客户端缓存资源以提高性能。 Rails 资产管道指南中对此进行了介绍
。采用此策略的副产品之一是您必须预编译生产文件。这是通过 Rails 内置的特殊任务完成的,通常由 Capistrano 在部署期间运行(您需要进行设置 - 详细信息在指南中)。
此外,当您的 js 和 css 文件不在清单中(默认的 application.css 和 application.js)时,它们不会被预编译,除非您将它们添加到配置变量中。
您能否编辑您的问题以包括如何链接到文件,并让我知道您是否正在使用清单以及是否正在预编译?
The string is called a fingerprint. Rails adds these in production mode to allow the assets to be cached on the client-side to improve performance. This is covered in the Rails asset pipeline guide
One of the by-products of adopting this strategy is that you must pre-compile your files for production. This is done via a special task built in to Rails, and is usually run by Capistrano during deployment (you need to set this up - details are in the guide).
Also, when you have js and css files that are not in a manifest (the default application.css and application.js) they don't get precompiled unless you add them into a config variable.
Can you edit your question to include how you link to the files and also let me know if you are using the manifests and if you are precompiling or not?
我也有同样的问题。
所选答案下的评论不适合我,但以下内容对我有用:
谢谢。
Same issue I have.
The comment under the selected answer did not for me, but the following works for me:
Thanks.