加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 每次部署后Paperclip文件都会被删除

发布时间:2020-12-17 03:56:40 所属栏目:百科 来源:网络整理
导读:我使用Paperclip gem来存储图片,而在localhost上它可以很好地工作.但是,我添加到我的实时应用程序的任何图片在每次部署后都会被删除. 我使用Git进行部署.这是我的部署过程: $bundle exec cap production deploy$ssh root@xx.xxx.xx.xxx$chmod -R 777 /rails
我使用Paperclip gem来存储图片,而在localhost上它可以很好地工作.但是,我添加到我的实时应用程序的任何图片在每次部署后都会被删除.

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

$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

有没有其他人遇到这样的事情?

更新:

这不是重复,因为this question的答案是将此行添加到我的deploy.rb:

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

导致Paperclip完全破裂.以前我遇到过无法使用Paperclip添加图片的问题,导致此错误:

Errno::EACCES in UsersController#update
Permission denied - /rails_apps/website/releases/20150807222222/public/system/users/avatars/000/000/562

但是在我的服务器上运行此命令会修复权限:

chmod -R 777 /rails_apps/website/releases

但是,如上所示修改我的deploy.rb文件会导致chmod -R 777命令不再起作用,并且我再次无权添加图像,从而导致相同的“Permission denied”错误.

所以这个问题不能为我的问题提供有效的解决方案.

解决方法

你在这做什么:

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

实际上是将你的“公共/系统”文件夹从/ rails_apps / website / releases / 20150807222222 / public / system符号链接到/ rails_apps / website / shared / public / system,这样图片总是存储在共享目录中,而不会丢失在部署.所以你应该做的是为共享文件夹设置适当的权限.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读