它正在运行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"
生产与开发是否需要特殊的路线? (或者是出于其他原因?)
最佳答案
你需要设置
config.serve_static_assets = true
在
config/environments/production.rb
中。它可能已经在那里被注释掉了。默认情况下,Rails不会在生产中单独提供静态文件,因为像Nginx或Apache这样的全功能Web服务器将始终自动为它们提供服务。
关于ruby-on-rails - 为什么 "rails server -e production"使其成为 "No route matches "/”,并且样式表无法加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5287805/