7646e982d3
- creator polymorphic instead of user - implementation
25 lines
572 B
Ruby
25 lines
572 B
Ruby
class Comment < ActiveRecord::Base
|
|
include ActsAsCommentable::Comment
|
|
|
|
belongs_to :commentable, :polymorphic => true
|
|
|
|
default_scope -> { order('created_at ASC') }
|
|
|
|
# NOTE: install the acts_as_votable plugin if you
|
|
# want user to vote on the quality of comments.
|
|
#acts_as_voteable
|
|
|
|
# NOTE: Comments belong to a creator
|
|
belongs_to :creator, polymorphic: true
|
|
|
|
def thread(commentable=:self)
|
|
commentable = self.commentable if commentable == :self
|
|
if commentable.nil?
|
|
[]
|
|
else
|
|
Comment.where(commentable: commentable)
|
|
end
|
|
end
|
|
|
|
end
|