它正在运行 Rails 3.0.0 或 Rails 3.0.5(使用 Ruby 1.9.2)
当处于开发模式时
rails server
then http://本地主机:3000 http://localhost:3000一切正常,并且http://localhost:3000/foos http://localhost:3000/foos将加载一个stylesheet.css
但当它是
rails server -e production
然后现在突然间http://本地主机:3000 http://localhost:3000 gives:
No route matches "/"
and http://localhost:3000/foos http://localhost:3000/foos可以运行,但是stylesheet.css
未加载并在浏览器中打开它显示:
No route matches "/stylesheets/scaffold.css"
生产与开发是否需要特殊路线? (或者是因为其他原因?)
你需要设置
config.serve_static_assets = true
in config/environments/production.rb
。它可能已经在那里被注释掉了。
默认情况下,Rails 在生产中不会自行提供静态文件,因为像 Nginx 或 Apache 这样的完整 Web 服务器无论如何都会自动提供静态文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)