class Comment < ApplicationRecord include CensorBear::RecordHook belongs_to :user, required: true def censor_show_path Rails.application.routes.url_helpers.comment_path(id) end def censor_text_partial_path "/comments/text_censor" end def censor_image_partial_path "comments/image_censor" end def censor_image_url(review_log) # 根据记录, 反推出图片的地址 # 如果图片是动态生成的 url 地址, 则应该通过 review_log 中的 image_id 来反推出图片的地址 # 若是静态的, 则直接返回 review_log.url 即可 review_log.url end def discarded? true end def censor_reject end def censor_undo_reject end def censor_delete destroy end def censor_approve update_columns(is_approved: true) end def censor_undo_approve update_columns(is_approved: false) end def censor_remove end def censor_undo_remove end def censor_ban_user user.ban! end def is_private [true, false].sample end end