Class: Attaching

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/sga/attaching.rb

Instance Method Summary collapse

Instance Method Details

#after_createObject



5
6
7
8
9
# File 'lib/sga/attaching.rb', line 5

def after_create
  if self.attachable.acts_as_polymorphic_paperclip_options[:counter_cache]
    self.attachable.class.increment_counter(:assets_count, self.attachable.id)
  end
end

#after_destroyObject



11
12
13
14
15
# File 'lib/sga/attaching.rb', line 11

def after_destroy
  if self.attachable.acts_as_polymorphic_paperclip_options[:counter_cache]
    self.attachable.class.decrement_counter(:assets_count, self.attachable.id)
  end
end