简体   繁体   English

Rails 3-从开发到生产的转变-公共资产404

[英]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.

相关问题 在轨道3.2.6中从开发切换到生产 - Switching from development to production in rails 3.2.6 将Twitter Boostrap网站从开发转移到生产–将LESS编译为CSS - Moving Twitter Boostrap site from development to production – Compiling LESS to CSS 为什么在 reactjs 从开发到生产构建时基本字体大小会发生变化 - Why does the base font size change when moving from development to production build in reactjs Rails资产位于子目录中,无法在生产中加载 - Rails assets are in a sub directory and cannot load in production Rails资产没有预编译,css在生产中看起来不同 - Rails assets not precompiling, css looks different in production 资产不是在Ruby on Rails的开发级别上编译的 - Assets are not compiled on the Development Level of Ruby on rails Rails路由错误与公用文件夹中的资产 - Rails route errors with assets in public folder Rails:从用户的localhost而不是Ubuntu服务器加载生产资产 - Rails: Production assets loading from user's localhost instead of Ubuntu server 开发和生产之间的Rails 4应用在视觉上有所不同 - Rails 4 app visually different between development and production Ruby on Rails-/ stylesheet目录中的样式表而不是/ assets中的样式表,生产中没有指纹 - Ruby on Rails - Stylesheets in /stylesheet directory and not in /assets, no fingerprint in production
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM