Module: ActAsStorage

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/act_as_storage.rb

Instance Method Summary collapse

Instance Method Details

#recalculate_storage_counters!Object



8
9
10
11
12
13
14
15
# File 'app/models/concerns/act_as_storage.rb', line 8

def recalculate_storage_counters!
  af = attached_files.pluck(:attachment_file_size)
  self.storage_files_count = af.count
  self.storage_files_size  = af.sum
  save

  self.try(:user).try(:recalculate_all_attached_files!)
end