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'
- bundle exec rake assets:precompile
- rails s
原因在下面: 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