它正在运行Rails 3.0.0或Rails 3.0.5(使用Ruby 1.9.2)
处于开发模式时
rails server
然后http://localhost:3000工作正常,http://localhost:3000/foos将加载stylesheet.css
但是当它
时rails server -e production
然后突然间,http://localhost:3000给出了:
No route matches "/"
和http://localhost:3000/foos可以运行,但未加载stylesheet.css
并在浏览器中打开它显示:
No route matches "/stylesheets/scaffold.css"
生产与开发需要特殊的路线吗? (还是出于其他原因?)
答案 0 :(得分:19)
您需要设置
config.serve_static_assets = true
config/environments/production.rb
中的。它可能已经在那里被评论过了。
默认情况下,Rails不会在生产中自行提供静态文件,因为像Nginx或Apache这样的完整Web服务器无论如何都会自动为它们提供服务。