Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?)

like image 820
nonopolarity Avatar asked Mar 13 '11 06:03

nonopolarity


1 Answers

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.

like image 190
Andrew Marshall Avatar answered Sep 28 '22 17:09

Andrew Marshall