MorningPeak/app/models/comment.rb
Arthur Poulet 7646e982d3 fix comment, implementation
- creator polymorphic instead of user
- implementation
2015-07-25 22:30:19 +02:00

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