16 lines
646 B
Ruby
16 lines
646 B
Ruby
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
|