app/models/comment.rb in tkh_content-0.9.15 vs app/models/comment.rb in tkh_content-0.9.16
- old
+ new
@@ -4,12 +4,12 @@
# end
class Comment < ActiveRecord::Base
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
- belongs_to :page
+ belongs_to :commentable, polymorphic: true
- validates_presence_of :page_id, :body
+ validates_presence_of :commentable_type, :commentable_id, :author_id, :body
scope :showable, -> { where('status = ? OR status = ?', 'pending', 'accepted') }
scope :pending, -> { where('status = ?', 'pending') }
scope :accepted, -> { where('status = ?', 'accepted') }
scope :blocked, -> { where('status = ?', 'blocked') }