Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yyandrew/0ab0dc59ee5093637467 to your computer and use it in GitHub Desktop.
Save yyandrew/0ab0dc59ee5093637467 to your computer and use it in GitHub Desktop.
#create capistrano task to run rake task of rails
# add below code to deploy.rb
desc "recreate version of all images."
task :recreate_version_of_images do
on roles(:app) do
within "#{current_path}" do
with rails_env: :production do
execute :rake, "images:recreate_version"
end
end
end
end
# add below code in lib/tasks/image.rake
namespace :images do
desc "Recreate versions of image"
task recreate_version: :environment do
puts "begin rake~~~"
Image.all.each do |image|
if !image.read_attribute(:image).nil?
image.image.recreate_versions! if image.image?
else
image.destroy
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment