hps_member/app/models/hps_member.rb

53 lines
1.2 KiB
Ruby

class HpsMember
include Mongoid::Document
include Mongoid::Timestamps
include ActiveModel::SecurePassword
# commmon values
field :account
field :password_digest, type: String
field :name
field :title
field :telephone
field :mobile
field :hps_city_id
field :hps_county_id
field :address
field :email
field :score, type: Integer, :default => 0
field :enabled, :type => Boolean, :default => true
field :user_type, type: Integer
field :old_id
# school type
field :hps_school_id
# counselor type
field :affilated_committees, type: Array, :default => []
field :organization
field :responsible_counties, type: Array, :default => []
field :year, type: Array, :default => []
has_secure_password
validates :account, uniqueness: true
# validates :password, :on => [:create]
has_many :hps_files, :dependent => :destroy
has_many :hps_results, :dependent => :destroy
has_many :hps_counseling_records, :dependent => :destroy
def get_user_type
case self.user_type
when 0
I18n.t("member_counselor.type1")
when 1
I18n.t("member_counselor.type2")
when 2
I18n.t("member_counselor.type3")
end
end
end