[英]Rails 3 - Moving from Development to Production - Public Assets 404
I migrated a Rails 2.2.2 application to Rails 3.1. 我将Rails 2.2.2应用程序迁移到Rails 3.1。
In development mode: /var/www/project_dir# thin start --ssl
all the assets are found and served beautifully. 在开发模式下:
/var/www/project_dir# thin start --ssl
找到了所有资产并提供了精美的服务。
When I run in production mode: /var/www/project_dir# thin start --ssl -e production
当我在生产模式下运行时:
/var/www/project_dir# thin start --ssl -e production
all of the asset requests (JS,CSS and images) return a 404. 所有资产请求(JS,CSS和图像)均返回404。
The paths in development and production mode are identical. 开发和生产模式中的路径是相同的。
I have come to the point where I have exhausted all of my debugging ideas and have no ideas why when in production mode, none of the assets can be found. 我已经精疲力尽了所有调试思想,却不知道为什么在生产模式下找不到任何资产。
I did try migrating over to asset pipeline but that caused more problems that I don't think I can solve right now so I need to solve this with asset pipeline off. 我确实尝试过迁移到资产管道,但是这引起了更多我现在无法解决的问题,因此我需要关闭资产管道来解决此问题。
Any and all ideas are welcome and THANKS! 任何和所有想法都值得欢迎和感谢!
Details 细节
Web Server: Thin 1.5.0 Web服务器:Thin 1.5.0
Asset Pipleine: Off 资产Pi:关闭
Asset Directories: 资产目录:
/var/www/project_dir/public/images / var / www / project_dir / public / images
/var/www/project_dir/public/javascripts / var / www / project_dir / public / javascripts
/var/www/project_dir/public/stylesheets / var / www / project_dir / public / stylesheets
Generated Asset Paths (Development Mode) 生成的资产路径(开发模式)
<script src="/javascripts/jquery.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/jquery.alerts.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/application.js?1366806357" type="text/javascript"></script>
<link href="/stylesheets/jquery-ui.css?1361279500" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/jquery.alerts.css?1361279500" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/default.css?1361279499" media="screen" rel="stylesheet" type="text/css" />
Generated Asset Paths (Production Mode) 生成的资产路径(生产模式)
<script src="/javascripts/jquery.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/jquery-ui.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/jquery.alerts.js?1366806358" type="text/javascript"></script>
<script src="/javascripts/application.js?1366806357" type="text/javascript"></script>
<link href="/stylesheets/jquery-ui.css?1361279500" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/jquery.alerts.css?1361279500" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/default.css?1361279499" media="screen" rel="stylesheet" type="text/css" />
Apache would do this automagically for you but with Thin, you need to do the following: Apache会自动为您执行此操作,但是使用Thin,您需要执行以下操作:
In /config/environments/production.rb
在
/config/environments/production.rb
Set this directive to true: 将此指令设置为true:
config.serve_static_assets = true
That will enable production mode to read assets from the /public
folder 这将使生产模式能够从
/public
文件夹中读取资产
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.