lib/emotions/emotion.rb in emotions-0.1.1 vs lib/emotions/emotion.rb in emotions-0.1.2
- old
+ new
@@ -10,7 +10,17 @@
end
# Associations
belongs_to :emotional, polymorphic: true
belongs_to :emotive, polymorphic: true
+
+ # Callbacks
+ after_create :update_emotion_counter
+ after_destroy :update_emotion_counter
+
+ protected
+
+ def update_emotion_counter
+ self.emotive.update_emotion_counter(self.emotion)
+ end
end
end