|
|
|
@ -18,7 +18,7 @@ class Message < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
scope :root_nodes, -> { where("parent_id IS NULL") } #判断该信息是帖子还是回复。null为发布的帖子
|
|
|
|
|
scope :reply_nodes, -> { where("parent_id IS NOT NULL") }
|
|
|
|
|
scope :visible, -> { where(is_hidden: false)}
|
|
|
|
|
scope :visible, -> { where(is_hidden: false) }
|
|
|
|
|
scope :by_user, ->(user) { visible if user.nil? || !user.admin? }
|
|
|
|
|
scope :preload_messages, -> { includes(:author, :message_detail) }
|
|
|
|
|
scope :short, -> { select(:id, :subject, :created_on, :replies_count, :visits, :sticky, :praises_count) }
|
|
|
|
|