Search code examples
ruby-on-railsnginxpassengerassets

Ruby on Rails application can not find stylesheets and javascript in production environment?


I deploy a Ruby on Rails application in ubuntu with passenger and nginx, but it cannot find the css and js files in my application.

Here is the error message:

open() "/var/nginx/blog/public/stylesheets/application.css" failed (2: No such file or directory)

In fact, /var/nginx/blog/public/stylesheets/application.css don't exist actually, my js files is in /var/nginx/blog/app/assets/javascripts/, my css files is in /var/nginx/blog/app/assets/stylesheets

In my nginx.conf, I write this:

location ~ ^/(assets|images|javascripts|stylesheets|system)/ {
    expires max;
    add_header Cache-Control public;
}

It seems that this is the place which is wrong! But I comment this, it still cannot find js and css. how do I config to get these files?


Solution

  • Maybe you should put your assets in public/ folder. Do you try precompile the assets?

    rake assets:precompile