2016-12-10 14:01:34 +08:00
|
|
|
|
class User < ActiveRecord::Base
|
|
|
|
|
has_and_belongs_to_many :projects
|
|
|
|
|
has_and_belongs_to_many :missions
|
|
|
|
|
|
|
|
|
|
has_many :notes
|
2016-12-11 15:56:58 +08:00
|
|
|
|
|
|
|
|
|
has_secure_password # 等价于验证password_confirm和password是否相等,并且验证password是否存在
|
|
|
|
|
|
2016-12-29 20:31:43 +08:00
|
|
|
|
validates :name, presence: true, length: { maximum: 30 }
|
2016-12-11 15:56:58 +08:00
|
|
|
|
validates :email, presence: true, uniqueness: true, length: { maximum: 50},
|
|
|
|
|
format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
|
2016-12-28 13:34:43 +08:00
|
|
|
|
validates :password, length: { minimum: 6 },on:create
|
2016-12-29 20:31:43 +08:00
|
|
|
|
validates :phone, presence: true, format: { with: /\A[0-9]{11,11}\Z/i },
|
2016-12-26 10:44:14 +08:00
|
|
|
|
multiline: false
|
2016-12-10 14:01:34 +08:00
|
|
|
|
end
|