Rails production assets precompile, but appear blank in the browser

The Sass and JS files all get compiled correctly when I rake assets:precompile for production, I can see them in the public/assets folder. However when I try to run the app and view on a web browser it comes up as a 404. The filenames match the compiled files in the public/assets folder. Everything works fine on Dev, just like all of the other SO questions I came up with.

404 Error

This is my original application.scss

@import 'materialize/components/_color';
@import 'materialize/components/variables';
@import 'materialize';
@import url(https://fonts.googleapis.com/icon?family=Material+Icons);

.icon-block {
  padding: 0 15px;
}

.icon-block .material-icons {
  font-size: inherit;
}

and original application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require materialize-sprockets
//= require_tree .

I'm on Windows for development, deploying to a Ubuntu server for production. New to Rails, but I want to do it right!

Upvotes: 2

Views: 764

Answers (2)

Zapaf
Zapaf

Reputation: 11

for future googlers - nowadays 'serve_static_files' doesnt work. this got changed to: config.public_file_server.enabled = true for more help see the guide: here

Upvotes: 1

I set config.serve_static_files = true in config/environments/production.rb and that fixed it. I'll probably have to fiddle with that to get it to work with what will likely be an NGINX server later, but it works locally.

Upvotes: 0

Related Questions