开发者

Why "rails server -e production" makes it "No route matches "/" and stylesheet not loading?

开发者 https://www.devze.com 2023-02-16 17:24 出处:网络
It is running Rails 3.0.0 or Rails 3.0.5 (using Ruby 1.9.2) When in development mode rails server then http://localhost:3000 works all fine, and http://localhost:3000/foos will load up a styleshee

It is running Rails 3.0.0 or Rails 3.0.5 (using Ruby 1.9.2)

When in development mode

rails server

then http://localhost:3000 works all fine, and http://localhost:3000/foos will load up a stylesheet.css

but when it is

rails server -e production

then now all of a sudden, http://localhost:3000 gives:

No route matches "/"

and http://localhost:3000/foos can run, but the stylesheet.css is not loaded and opening it in the browser shows:

No route matches "/stylesheets/scaffold.css"

Is special开发者_运维技巧 route needed for production vs development? (or is it for some other reason?)


You need to set

 config.serve_static_assets = true

in config/environments/production.rb. It's likely commented out in there already.

By default Rails does not serve static files by itself in production, since full-on web servers like Nginx or Apache, will serve them automatically anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消