hps_member/app/models/hps_member.rb

51 lines
1.1 KiB
Ruby
Raw Normal View History

2017-05-18 12:12:35 +00:00
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
2017-05-24 08:57:46 +00:00
field :old_id
2017-05-18 12:12:35 +00:00
# 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], length: {:in => 8..20}
has_many :hps_files, :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