ask/app/models/ask_question.rb

36 lines
928 B
Ruby
Raw Normal View History

2014-10-02 06:00:35 +00:00
class AskQuestion
include Mongoid::Document
include Mongoid::Timestamps
2014-10-23 07:03:21 +00:00
# include ActiveModel::Validations
2014-10-02 06:00:35 +00:00
include OrbitCategory::Categorizable
2014-10-23 07:03:21 +00:00
include OrbitTag::Taggable
2014-10-02 06:00:35 +00:00
# 欄位
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
2014-10-23 07:03:21 +00:00
field :situation, type: String, default: "is_waiting" #預設待處理
2014-10-02 06:00:35 +00:00
field :send_email, type: Boolean, default: false
field :email_id
2014-10-23 07:03:21 +00:00
# validates_presence_of :name, :identity, :mail, :title, :content
2014-10-02 06:00:35 +00:00
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