Sha256: e5adb8cdf2aacc13e90f8b6310ab5489938595d18885967ebe4420c0f31e5836

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

require 'ruby-progressbar'

namespace :assets do
  # rake assets:reprocess CLASS=PostImage
  desc 'Refresh carrierwave assets versions by model (CLASS=)'
  task reprocess: :environment do
    name = (ENV['CLASS'] || ENV['class'] || 'Asset').to_s
    klass = name.safe_constantize

    raise "Cannot find a constant with the #{name} specified in the argument string" if klass.nil?

    bar = ProgressBar.create(title: name, total: klass.count, format: '%c of %C - %a %e |%b>>%i| %p%% %t')
    bar.progress_mark = '='

    klass.find_each do |item|
      begin
        item.data.recreate_versions!
        bar.increment
      rescue => e
        puts "ERROR recreate_versions for #{name} - #{item.id}: #{e.message}"
      end
    end

    bar.finish
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ab_admin-0.4.0 lib/tasks/assets.rake