Sha256: 831cd2c9de2c3720b8dfd91fc4bce144cd7e63d3df2d366b0638305b0c2f9415

Contents?: true

Size: 362 Bytes

Versions: 1

Compression:

Stored size: 362 Bytes

Contents

module ActAsStorage
  extend ActiveSupport::Concern

  included do
    has_many :attached_files,  as: :storage
  end

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
the_storages-0.0.2 app/models/concerns/act_as_storage.rb