|
|
@ -4,11 +4,11 @@ require 'github/markup' |
|
|
|
class Comment < ApplicationRecord |
|
|
|
belongs_to :user |
|
|
|
belongs_to :parent, class_name: "Comment", optional: true |
|
|
|
belongs_to :post |
|
|
|
belongs_to :post, touch: true |
|
|
|
has_many :replies, class_name: "Comment", foreign_key: :parent_id |
|
|
|
|
|
|
|
def editable_by?(user) |
|
|
|
# Will need to consider how this should work when/if comment editing is supported |
|
|
|
return self.user_id == user.id || user.admin? || self.post.blog.user_id == user.id |
|
|
|
self.user_id == user.id || user.admin? || self.post.blog.user_id == user.id |
|
|
|
end |
|
|
|
end |