Images I upload to my rails app with picture_uploader.rb disappear after each new 'cap deploy'.
# picture_uploader.rb
class PictureUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process resize_to_limit: [500, 500]
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{Rails.env}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
Capistrano deploys my app to:
/var/www/myapp_app/
so the physical storage location resulting from the above configuration is:
/var/www/myapp_app/releases/20150608000412/uploads/micropost/production/338/example_photo.jpg
and the image path rendered in a web browser becomes:
https://example.com/uploads/micropost/production/338/example_photo.jpg
Uploaded images appear to work at first but then disappear the next time I run 'cap deploy'.
Thanks in advance for any help.
I figured it out. The problem was in config/deploy/production.rb. I needed to add 'public/uploads' to my linked_dirs like this:
so that Capistrano will create the shared/public/uploads/ directory (if not present) and symlink each new deploy release to it.