CSS doesn't load in production - everything fine in dev (Rails 4.1, Capistrano 3; bootstrap), update: nginx config issue

风流意气都作罢 提交于 2019-12-06 05:31:28

Several things to test:

  • When you precompile your assets, do the required files appear in your public directory?

When you precompile your assets, you basically tell the Rails asset pipeline to merge & compile all your assets in the public directory. This means if you're trying to include a particular file in your production asset pipeline, it should be precompiled

I would run the rake assets:precompile RAILS_ENV=production command, and then look at all your assets in the public folder to check if they're there

--

  • If the assets are present in your public folder, are they being pushed to the server?

You should SSH into your server & browse to the public directory of your app (in /current). This will allow you to see if your assets have been uploaded to your server as you need

If they are not there, the problem is with Capistrano's deploy process; if they are there, it means there's a problem with your Rails server

--

  • If the assets are in the public folder on your server, it will mean the server is at fault somehow

Probably the best way to ensure it's not a server issue is to reload the server. With apache, you'll typically use service reload apache2, but I'm not sure about nginx.

This should be accompanied by looking at your Rails installation - is it calling the correct assets as defined in your config files?

This is a bit off topic, but for organization's sake you might want to put your Nginx server block in /etc/nginx/sites-available/default and then make sure you have it linked to /etc/nginx/sites-enabled/default.

It should work fine with the server block in /etc/nginx/nginx.conf but it's best practice to put it in the default host or create another virtual host if you so desire.

Glad you were able to get things working.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!