1

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?

2 Answers 2

3

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

rake assets:precompile

Sign up to request clarification or add additional context in comments.

2 Comments

this is the standard directory structure of ruby on rails application, you mean I run rake assets:precompile in Ubuntu?
I think that Vladis answer is correct! the correct command is: RAILS_ENV=production rake assets:precompile
2

You should to run RAILS_ENV=production bundle exec rake assets:precompile on remote server where you deploying.

assets:precompile rake task compressing and minimizing your assets for fast and reliable high-load production usage. Do not need to run this task on your development enviroment.

Would be better if you can show your deploy script. But most of deployment solutions like capistrano automaticaly doing this things right.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.