每次部署后都会删除回形针文件 [英] Paperclip files get deleted after each deploy

查看:29
本文介绍了每次部署后都会删除回形针文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Paperclip gem 来存储图片,并且在 localhost 上它运行良好.但是,每次部署后,我添加到实时应用中的所有图片都会被删除.

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.

我使用 Git 进行部署.这是我的部署过程:

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?

更新:

这不是重复的,因为这个问题的答案,就是添加这行到我的 deploy.rb:

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')

导致回形针完全断裂.之前我遇到过无权使用 Paperclip 添加图像的问题,导致此错误:

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

但是,如上所示修改我的 deploy.rb 文件,导致 chmod -R 777 命令不再起作用,并且我再次没有添加图像的权限,导致同样的权限被拒绝"错误.

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.

推荐答案

你在这里做什么:

set :linked_dirs, fetch(:linked_dirs, []).push('public/system')

实际上是将您的public/system"文件夹从 /rails_apps/website/releases/20150807211111/public/system 符号链接到 /rails_apps/website/shared/public/system ,以便图片始终存储在共享目录中,并且不会在部署时丢失.所以你应该做的是为共享文件夹设置适当的权限.

is actually symlinking your "public/system" folder from /rails_apps/website/releases/20150807211111/public/system to /rails_apps/website/shared/public/system , so that the pictures are always stored in the shared directory, and not lost on deploy. So what you should actually do is set the proper rights for the shared folder.

这篇关于每次部署后都会删除回形针文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆