问题描述
我正在构建一个VPS,并且它通过Capistrano,数据库连接等进行了部署,但是该页面没有可用的资产-仅是基本的html.
I'm building a VPS, and it's deployed via Capistrano, database connected etc, but there are no assets available to the page - it is basic html only.
资产似乎已被编译,并存在于共享目录中.
The assets appear to be compiled, and exist in the shared directory.
从html页面:
<link href="/assets/application-a1b5d69aeaff709fd3dce163c559b38b.css" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application-0ebd07089629f8c6880dddfb688d525d.js" type="text/javascript"></script>
资产文件似乎存在于共享目录中:
The asset files appear to exist in the shared directory:
assay@assaypipeline:~/apps/assay/shared/assets$ ls application- a1b5d69aeaff709fd3dce163c559b38b.css
application-a1b5d69aeaff709fd3dce163c559b38b.css
当我查看,来源,然后单击指向资产路径的超链接时,我从Nginx处找不到404.
When I view, source and then click on the hyperlink to the asset path, I get a 404 not found from Nginx.
解决方案
感谢Martin M(可接受的答案)寻求帮助.我从服务器上的〜/apps/(应用名称)/当前目录执行的步骤.
Thanks to Martin M (accepted answer) for help. The steps I took, from the ~/apps/(app name)/current directory on the server.
$ bundle install
$ RAILS_ENV=production bundle exec rake assets:precompile
$ sudo service nginx restart
显然,将其包含在Capistrano配方中会更好.
Obviously it would be better to include this in the Capistrano recipe.
* EDIT-Capfile *
load 'deploy'
load 'deploy/assets'
load 'config/deploy'
推荐答案
您的预编译资产应位于public/assets
中,请参见导轨指南
通常,您可以通过运行
Your precompiled assets should reside in public/assets
, see rails guides
normally you create them by running
RAILS_ENV=production bundle exec rake assets:precompile
作为部署的一部分.
共享的内容是在多个部署中提供旧的内容.
as part of your deployment.
The shared stuff is to provide old stuff over several deploys.
另请参阅此问题
这篇关于Capistrano部署后缺少Rails资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!