master
1class Favorite < ApplicationRecord
2 belongs_to :user
3 belongs_to :creation, counter_cache: true, touch: true
4 after_create :create_activity
5
6 def create_activity
7 transaction do
8 Activity.create(user: creation.author, subject: self)
9 creation.author.notify_of_activity
10 end
11 end
12end