Carrierwave files with Capistrano

后端 未结 5 1013
轮回少年
轮回少年 2020-12-07 21:18

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 d

5条回答
  •  盖世英雄少女心
    2020-12-07 21:34

    Go to your app server shared folder and create an uploads directory.

    mkdir uploads

    In your deploy.rb file insert these codes under deploy namespace

    task :symlink_uploads do

    run "rm -rf #{latest_release}/public/uploads && ln -nfs #{shared_path}/uploads #{latest_release}/public/uploads"

    end

    after 'deploy:update_code', 'deploy:symlink_uploads'

    Now delete the old files present already as they won't work. Upload a new file and cap deploy your app again. It should work now.

提交回复
热议问题