main
rb 17 lines 341 Bytes
Raw
1 # frozen_string_literal: true
2
3 # A comment on an issue or pull request (polymorphic `commentable`).
4 class Comment < ApplicationRecord
5 belongs_to :commentable, polymorphic: true
6 belongs_to :user # author
7
8 validates :body, presence: true
9
10 def author
11 user
12 end
13
14 def html_url
15 "#{commentable.html_url}#comment-#{id}"
16 end
17 end