I use the Paperclip gem to store pictures, and on localhost it works perfectly. However, any pictures I add to my live app get deleted after every deploy.
I use Git to deploy. Here's my deployment process:
$ bundle exec cap production deploy
$ ssh root@xx.xxx.xx.xxx
$ chmod -R 777 /rails_apps/app/releases
$ cd /rails_apps/app/current
$ cp config/database.yml.sample config/database.yml
$ RAILS_ENV=production bundle exec rake assets:precompile
$ /etc/init.d/apache2 restart
Has anyone else run into something like this?
UPDATE:
This is not a duplicate, because the answer to this question, which is to add this line to my deploy.rb:
set :linked_dirs, fetch(:linked_dirs, []).push('public/system')
causes Paperclip to break entirely. Previously I had had an issue with not having permission to add images with Paperclip, resulting in this error:
Errno::EACCES in UsersController#update
Permission denied - /rails_apps/website/releases/20150807211111/public/system/users/avatars/000/000/562
But running this command on my server fixes the permissions:
chmod -R 777 /rails_apps/website/releases
However, modifying my deploy.rb file as shown above, causes the chmod -R 777 command to no longer work, and I once again don't have permission to add images, resulting in the same "Permission denied" error.
So that question does not supply a valid solution to my problem.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire