在生产模式下运行瘦服务器不会加载我的资源
当我像这样加载 thin
时:
thin start -e production
并尝试访问我的其中一个页面时,我在日志输出中得到以下信息:
cache: [GET /] miss
cache: [GET /assets/main-bd1ef4b153740fb69fd615304b87ad0d.css] miss
cache: [GET /assets/jqModal-8fa734bf4f58524b2799abd73ab7d34f.css] miss
cache: [GET /assets/jquery-544665ba1d5b4f793290421aafed85c9.js] miss
cache: [GET /assets/application-00b97aa2429046c0c43802f07b756b46.js] miss
这些文件存在于我的 assets
目录下的 public 下
。
我也运行了这个命令:
RALS_ENV=production rake assets:precompile
我尝试在浏览器中访问文件 /public/assets/application.js
,如下所示:
http://localhost:3000/application.js
这给了我一个 404 错误(即使该文件存在于/public/assets
但是当我在服务器处于开发模式时向文件发出请求时可以读取该文件
有人有什么想法吗?
When I load thin
like so:
thin start -e production
and try to access one of my pages, I get this in the log output:
cache: [GET /] miss
cache: [GET /assets/main-bd1ef4b153740fb69fd615304b87ad0d.css] miss
cache: [GET /assets/jqModal-8fa734bf4f58524b2799abd73ab7d34f.css] miss
cache: [GET /assets/jquery-544665ba1d5b4f793290421aafed85c9.js] miss
cache: [GET /assets/application-00b97aa2429046c0c43802f07b756b46.js] miss
These files exist in my assets
directory under public
.
I've run this command also:
RALS_ENV=production rake assets:precompile
I've tried just accessing the file /public/assets/application.js
in the browser like this:
http://localhost:3000/application.js
Which gives me a 404 error (even though the file exists in /public/assets
but the file can be read when I make a request to the file when the server is in development mode.
Anyone have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,Rails 在生产环境 (
config/environments/Production.rb
) 中关闭提供静态文件的服务:瘦服务器未配置为提供静态资产,因此对资产的请求失败。
Rails serving static files is turned off in production (
config/environments/production.rb
) by default:The Thin server is not configured to serve the static assets, and so requests to your assets are failing.