带有 Capistrano 的 Carrierwave 文件 [英] Carrierwave files with Capistrano
问题描述
我正在使用带有资产和载波的 rails 3.2 上传一些图像,它们存储在/public/uploads/photo/.....但是当我执行 cap:deploy(使用 capistrano)时,我当前的目录应用程序不包含我上传的文件,因为 capistrano 制作了一个新版本......
=== 更新 ===
毕竟我用过这个:
在 :deploy 命名空间内
任务 :symlink_uploads 做运行ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"结尾
及之后:
'deploy:update_code', 'deploy:symlink_uploads' 之后
=== 重新更新 ===
@tristanm 的解决方案是解决这个问题的最好方法.
这个怎么样:
# config/deploy.rb设置 :shared_children, shared_children + %w{public/uploads}
:shared_children
默认为 %w(public/system log tmp/pids)
所以我们只是扩展这个列表.
不要忘记在更改 :shared_children
后运行 cap deploy:setup
以便在 shared
下创建新目标.>
编辑 Capistrano 3:
Capistrano 3 使用 linked_dirs
设置并且不再指定 public/system
作为默认设置.
set :linked_dirs, fetch(:linked_dirs) + %w{public/system public/uploads}
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 ....
=== Update ===
After all I use this :
inside :deploy namespace
task :symlink_uploads do
run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
end
and after:
after 'deploy:update_code', 'deploy:symlink_uploads'
=== Re Update ===
The solution of @tristanm is the best way to solve this.
How about this:
# config/deploy.rb
set :shared_children, shared_children + %w{public/uploads}
:shared_children
defaults to %w(public/system log tmp/pids)
so we're just expanding this list.
EDIT:
Don't forget to run cap deploy:setup
after changing :shared_children
so that the new targets are created under shared
.
EDIT Capistrano 3:
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 的 Carrierwave 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!