announcement-test/app/models/bulletin_comment.rb

21 lines
536 B
Ruby
Raw Permalink Normal View History

2020-07-30 14:12:21 +00:00
# encoding: utf-8
class BulletinComment
include Mongoid::Document
include Mongoid::Timestamps
field :ip
field :comment
field :account_id
field :is_hidden,type: Boolean,default: false
def time
self.created_at.strftime('%Y/%m/%d %H:%M')
end
def account
tmp = MemberProfile.where(:id => self.account_id).collect{|v| v.name}.join
tmp.blank? ? I18n.t('announcement_visitor') : tmp
end
def roles
MemberProfile.where(:id => self.account_id).collect{|v| v.roles}.flatten
end
belongs_to :bulletin
end