QuestionEverything
QuestionEverything

Reputation: 5097

rails 4 static assets not being served even after setting config.serve_static_assets = true

I've created a rails 4, ruby 2 app. In development mode, it's working fine. But if I start the server in production mode, it fails to serve all the images and javascript files.

I've set config.serve_static_assets = true in my production.rb. Still, I get a 404 error. What could be the possible reason? Any help would be highly appreciated.

Upvotes: 0

Views: 1421

Answers (1)

Richard Hulse
Richard Hulse

Reputation: 10493

When running the server in production mode the system expects that the assets will be precompiled and available in the public folder.

To test this you should run the precompile task. You'll see that a folder called assets is created inside of the public folder, and inside this all your assets will be created.

WARNING: You should delete this folder when you are done testing, and clear the asset cache in the /tmp folder before going back to dev mode. Failing to do this will result in the app serving the precompiled assets in dev mode and you won't see any changes that you make.

Upvotes: 1

Related Questions