module CarrierWaveDelay module Model extend ActiveSupport::Concern included do cattr_accessor :carrierwave_delay_columns end module ClassMethods def carrierwave_delay columns after_save :carrierwave_delay_process self.carrierwave_delay_columns = columns end def carrierwave_delay_queue :default end def carrierwave_delay_priority 20 end end def recreate_delayed_versions! self.class.carrierwave_delay_columns.each do |column| unless self.send(column).nil? send(column).is_processing_delayed = true send(column).recreate_versions! end end end private def carrierwave_delay_process self.delay(queue: self.class.carrierwave_delay_queue, priority: self.class.carrierwave_delay_priority).recreate_delayed_versions! end end end