Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

ruby on rails - Carrierwave files with 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 ....

=== 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...