summaryrefslogtreecommitdiff
path: root/app/models/comment.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-01-18 22:54:37 -0700
committermo khan <mo@mokhan.ca>2014-01-18 22:54:37 -0700
commite0ce9c098d0b82e2ae999b4e80f11c82fa65f78d (patch)
tree7ca8fd4e6a1dde56c10a7032860a5d3732a9e42c /app/models/comment.rb
parenta8ccb349d975166ff33935b19548018eeb4f24f7 (diff)
create a new activity when a comment is created.
Diffstat (limited to 'app/models/comment.rb')
-rw-r--r--app/models/comment.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 05cf9954..72b4dc5c 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -1,4 +1,12 @@
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :creation
+ has_many :activities, as: :subject
+ after_create :create_activity
+
+ private
+
+ def create_activity
+ Activity.create(user: user, subject: self)
+ end
end