ambition/app/models/user.rb

16 lines
646 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class User < ActiveRecord::Base
has_and_belongs_to_many :projects
has_and_belongs_to_many :missions
has_many :notes
has_secure_password # 等价于验证password_confirm和password是否相等并且验证password是否存在
validates :name, presence: true, uniqueness: true, length: { maximum: 30 }
validates :email, presence: true, uniqueness: true, length: { maximum: 50},
format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
validates :password, length: { minimum: 6 },on:create
validates :phone, presence: true, uniqueness: true, format: { with: /\A[0-9]{11,11}\Z/i },
multiline: false
end