Created
September 17, 2014 03:46
-
-
Save yyandrew/0ab0dc59ee5093637467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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