user.rb
505 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class User < ApplicationRecord
belongs_to :company
validates \
:first_name,
:last_name,
:email,
presence: true
validates \
:email,
uniqueness: {
case_insensitive: true
}
def active?
archived_at.blank?
end
def archived?
archived_at.present?
end
def archive!
write_attribute(:archived_at, Time.now)
save!
end
def unarchived?
archived_at.blank?
end
def unarchive!
write_attribute(:archived_at, nil)
save!
end
end