Skip to content
Newer
Older
100644 17 lines (15 sloc) 557 Bytes
70bb9d2 initial commit
heavysixer authored
1 class Attaching < ActiveRecord::Base
2 belongs_to :asset, :counter_cache => true
3 belongs_to :attachable, :polymorphic => true
428edf9 @cantorrodista fix scope of acts as list
authored
4 acts_as_list :scope => :attachable
70bb9d2 initial commit
heavysixer authored
5
6 def after_create
7 if self.attachable.acts_as_polymorphic_paperclip_options[:counter_cache]
8 self.attachable.class.increment_counter(:assets_count, self.attachable.id)
9 end
10 end
11
12 def after_destroy
13 if self.attachable.acts_as_polymorphic_paperclip_options[:counter_cache]
14 self.attachable.class.decrement_counter(:assets_count, self.attachable.id)
15 end
16 end
17 end
Something went wrong with that request. Please try again.