announcement-test/app/models/bulletin_comment.rb

21 lines
536 B
Ruby

# 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