forked from saurabh/orbit4-5
18 lines
517 B
Ruby
18 lines
517 B
Ruby
|
class User
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
include ActiveModel::SecurePassword
|
||
|
|
||
|
field :user_name, type: String
|
||
|
field :email, type: String
|
||
|
field :password_digest, type:
|
||
|
|
||
|
has_secure_password
|
||
|
|
||
|
VALID_EMAIL_FORMAT = /\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z/
|
||
|
|
||
|
validates :user_name, presence: true, uniqueness: true
|
||
|
validates :password, presence: true, :on => :create, length: {:in => 8..20}
|
||
|
validates :email, presence: true, uniqueness: true, format: { with: VALID_EMAIL_FORMAT }
|
||
|
end
|