4

Every time I upload images it goes to public/images/upload then when I run a cap deploy they get erased since it creates a new current directory.

How do I instruct Capistrano to move the files in public/images/upload to the shared/images/ then symlink those images to the current(new) release ?

after "deploy:update_code", "deploy:symlink_shared"
after "deploy:restart", "deploy:cleanup"

    namespace :deploy do
      task :restart do
        run "touch #{current_path}/tmp/restart.txt"
      end

      desc "Symlink shared configs and folders on each release."
      task :symlink_shared do
        run "ln -nfs #{shared_path}/images/upload #{release_path}/public/images/uploads"
      end
    end
gustavoanalytics
  • 584
  • 6
  • 18

1 Answers1

3

Have try to expand shared directory list?

#deploy.rb
set :shared_children, shared_children + %w{public/images/uploads}

Edit : Remove you code and set shared_children variable. After that make a cap deploy:setup so that updated your shared dir.

Yann VERY
  • 1,819
  • 14
  • 11
  • So you want me to set that in the deploy.rb and keep everything else? – gustavoanalytics Jan 04 '14 at 20:26
  • :shared_children is an array. Defaults values are %w(public/system log tmp/pids) We want to expand this list and add public/images/uploads to shared directory – Yann VERY Jan 04 '14 at 21:20
  • 1
    Great! you can use this syntax so : `set :shared_children, %w{images/ public/images/uploads}` – Yann VERY Jan 04 '14 at 21:40
  • `set :shared_children, shared_children + fetch(:upload_dirs)` gives me `undefined local variable or method `shared_children' for main:Object`. Was shared_children removed? – kettlepot Jan 13 '14 at 18:14
  • @GabrieleCirulli did you solve this problem? If so can you explain how [here](http://stackoverflow.com/questions/21837690/how-do-i-symlink-my-product-images-in-production-on-a-capistrano-deploy)? – user2609980 Feb 17 '14 at 22:09
  • 1
    This was the cap2 way. Use: `set :linked_dirs, %w(public/images/uploads)` – Casey Watson Aug 19 '14 at 16:26