seminar2_old/custom_announcement/app/models/custom_bulletin_comment.rb

21 lines
556 B
Ruby

# encoding: utf-8
class CustomBulletinComment
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('custom_announcement_visitor') : tmp
end
def roles
MemberProfile.where(:id => self.account_id).collect{|v| v.roles}.flatten
end
belongs_to :custom_bulletin
end