35 lines
888 B
Ruby
35 lines
888 B
Ruby
|
class AskQuestion
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
include ActiveModel::Validations
|
||
|
include OrbitCategory::Categorizable
|
||
|
|
||
|
# 欄位
|
||
|
field :name, type: String
|
||
|
field :identity, type: String
|
||
|
field :mail, type: String
|
||
|
field :phone, type: String
|
||
|
field :fax, type: String
|
||
|
field :title, type: String
|
||
|
field :content, type: String
|
||
|
|
||
|
field :reply, type: String
|
||
|
field :comment, type: String
|
||
|
field :status, type: String, default: "is_hot" #預設待處理
|
||
|
field :send_email, type: Boolean, default: false
|
||
|
field :email_id
|
||
|
|
||
|
validates_presence_of :name, :identity, :mail, :title, :content
|
||
|
|
||
|
def email
|
||
|
mail = Email.find(self.email_id) rescue nil
|
||
|
end
|
||
|
|
||
|
def email_address
|
||
|
email_address = AskAdmin.all.collect{|a| a.email} rescue []
|
||
|
# email_address = email_address +[self.mail] if !self.mail.blank?
|
||
|
email_address.flatten
|
||
|
end
|
||
|
|
||
|
end
|