简体   繁体   English

Capistrano未部署回形针图像

[英]Capistrano not deploying paperclip images

I have a Rails 4 app using the paperclip gem to store images at #{Rails.root}/public/system/... which works fine in development. 我有一个使用回形针gem的Rails 4应用程序,将图像存储在#{Rails.root} / public / system / ...上,在开发中效果很好。

I have checked a handful of the development images into the above folder, but they aren't appearing on the Ubuntu 13.10 EC2 instance that I am deploying to. 我已经将少数开发映像检入了上述文件夹,但是它们没有出现在我要部署到的Ubuntu 13.10 EC2实例上。 I am using Capistrano to deploy, and it seems to be creating all the symlinks fine: 我正在使用Capistrano进行部署,并且似乎可以很好地创建所有符号链接:

ls -l releases/20140402123457/public/system lrwxrwxrwx 1 ubuntu ubuntu 28 Apr 2 12:35 releases/20140402123457/public/system -> /var/www/alpha/shared/system

But the shared directory being linked to does not contain my images. 但是链接到的共享目录不包含我的图像。 How do I populate the /var/www/app/shared/public/system directory? 如何填充/ var / www / app / shared / public / system目录? I assumed Capistrano would do this for me, but it is empty. 我以为Capistrano会为我做这件事,但它是空的。

I have searched many capistrano / paperclip threads for the answer, and I have tried all the capistrano deploy commands I can find in Capistrano -T. 我已经搜索了许多capistrano /回形针线程来寻找答案,并且尝试了在Capistrano -T中可以找到的所有capistrano部署命令。 I believe I am using default locations for paperclip, and the paperclip documentation suggests the path I am using: https://github.com/thoughtbot/paperclip#understanding-storage 我相信我在为回形针使用默认位置,并且回形针文档建议了我正在使用的路径: https : //github.com/thoughtbot/paperclip#understanding-storage

My Gemfile.lock shows the Gems I am using here: http://pastebin.com/iDv1Qm5K . 我的Gemfile.lock在此处显示我正在使用的Gems: http ://pastebin.com/iDv1Qm5K。

I've been scratching my head and am staring to wonder if I am going mad. 我一直在挠挠头,想知道我是否会发疯。 Do I need to manually copy the development images into the shared/system directory? 我需要手动将开发映像复制到shared / system目录吗? I have checked the images are in git and are extracted when cloning, so I am hoping I have covered the basics on daft mistakes that could be causing this. 我已经检查了图像是否在git中,并在克隆时将其提取出来,所以我希望我已经涵盖了可能导致此错误的愚蠢错误的基本知识。 Any advice on how to investigate this further would be much appreciated. 任何有关如何进一步调查的建议将不胜感激。

Thanks to the tips from Marian Theisen, I have fixed this by moving the seed image files from the /app/public/system directory to /app/assets/seed_images/. 感谢玛丽安·泰森(Marian Theisen)的技巧,我通过将种子图像文件从/ app / public / system目录移动到/ app / assets / seed_images /来解决此问题。

I then created a cap deploy task in config/deploy.rb to copy the images over to the shared directory: 然后,我在config / deploy.rb中创建了一个cap部署任务,将映像复制到共享目录:

namespace :deploy do desc "Move seed images into place" task :move_seed_images_into_place, :roles => :app do run "cd #{release_path}; cp -R app/assets/seed_images/* #{shared_path}/system" end end

And added after("deploy:update_code", "deploy:move_seed_images_into_place") to my config/deploy/staging.rb file. after("deploy:update_code", "deploy:move_seed_images_into_place")到我的config / deploy / staging.rb文件中。

In short, the answer is that I was doing the wrong thing by trying to share public/system between my dev machine and staging hosts. 简而言之,答案是我通过尝试在开发机和暂存主机之间共享公共/系统来做错事。 Instead, I have moved the seed images to a named location and I manually move them into place on my staging hosts. 取而代之的是,我将种子图像移到了一个命名的位置,并手动将它们移到我的暂存主机上的适当位置。

This also has the benefit that I can trash the images I am using in development without trashing the install - I have a snapshot of the images I want saved in the app/assets/seed_images directory. 这还有一个好处,就是我可以在不破坏安装的情况下破坏开发中正在使用的图像-我将要保存的图像快照保存在app / assets / seed_images目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM