问题描述
我正在使用带有资产和载波的rails 3.2上传一些图像,它们存储在/ public / uploads / photo / ....
中,但是当我执行cap:deploy(使用capistrano)时,当前目录应用程序不包含我上传的文件,因为capistrano制作了新版本....
I'm using rails 3.2 with asset and carrierwave for upload some images, they store in /public/uploads/photo/..... but when I do a cap:deploy (with capistrano) my current directory application doesn't contain the files I uploaded, because capistrano make a new version ....
===更新===
毕竟我使用了这个:
inside:deploy名称空间
inside :deploy namespace
task :symlink_uploads do
run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
end
及之后:
after 'deploy:update_code', 'deploy:symlink_uploads'
===重新更新===
=== Re Update ===
@tristanm的解决方案是解决此问题的最佳方法。
The solution of @tristanm is the best way to solve this.
推荐答案
如何操作:
# config/deploy.rb
set :shared_children, shared_children + %w{public/uploads}
:shared_children
默认为%w(public / system log tmp / pids)
编辑:
别忘了运行更改:shared_children
后, cap deploy:setup
以便在 shared 。
Don't forget to run cap deploy:setup
after changing :shared_children
so that the new targets are created under shared
.
编辑Capistrano 3:
Capistrano 3使用 linked_dirs
设置,并且不再指定 public / system
作为默认值。
Capistrano 3 uses the linked_dirs
setting and doesn't specify public/system
as a default anymore.
set:linked_dirs,fetch(:linked_dirs)+%w {public / system public / uploads}
这篇关于Capistrano的载波文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!