Rails3程序在产品模式上出现assert文件404异常的有关问题
Rails3程序在产品模式下出现assert文件404错误的问题rails3程序部署产品模式之后 出现以下静态文件错误 Ru
Rails3程序在产品模式下出现assert文件404错误的问题
rails3程序部署产品模式之后
出现以下静态文件错误 Ruby代码:
- 17:14:26 INFO: Started GET "/assets/application-b42d228d39a3e30c7479d7bf2fd1709b.js" for 10.0.2.2 at 2013-03-07 17:14:26 +0800
- 17:14:26 FATAL:
- ActionController::RoutingError (No route matches [GET] "/assets/application-b42d228d39a3e30c7479d7bf2fd1709b.js"):
- actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
- actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
- railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
- railties (3.2.9) lib/rails/rack/logger.rb:18:in `call'
这个问题看上去像是assert资源的问题,首先要确保下面这个命令运行,编译静态文件 Ruby代码:
- bundle exec rake assets:precompile
我上面处先的问题是在这一步之后,我的启动方式,是 Ruby代码:
- rails s
开发模式样式表,js什么的都有,但是产品模式下就是上面那个问题了。
原因在下面: Ruby代码:
- # config/environments/production.rb
- ...
- config.serve_static_assets = false
- ...
上面是产品模式的配置,开发模式默认是没有这个选项的。
解决方案有两种:
方法一:是把上面那一行配置改成 true
方法二:是搭建nginx或者apache服务器,ngxin和apache会直接读取静态文件,不会产生这个问题
这是来自stackoverflow上的答案
引用In production mode, Rails will not be responsible for serving static assets. Therefore, you are getting this error. Thin won't do it either, since it's just a wrapper around Rails.
This is controlled by this setting in config/environment/production.rb in your application:
config.serve_static_assets = false
You can either set to that true or use a real server like Apache or Nginx which will serve the static assets. I suspect Pow may also do it.
share|improve this answer
其访问地址http://stackoverflow.com/questions/7829480/no-route-matches-get-assets
原文链接:http://www.software8.co/wzjs/qtyy/3255.html