forked from binarylogic/authlogic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.rb
More file actions
25 lines (22 loc) · 882 Bytes
/
Copy pathadmin.rb
File metadata and controls
25 lines (22 loc) · 882 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
# frozen_string_literal: true
# This model demonstrates an `after_save` callback.
class Admin < ActiveRecord::Base
acts_as_authentic do |c|
c.crypto_provider = Authlogic::CryptoProviders::SCrypt
end
validates :password, confirmation: true
after_save do
# In rails 5.1 `role_changed?` was deprecated in favor of `saved_change_to_role?`.
#
# > DEPRECATION WARNING: The behavior of `attribute_changed?` inside of
# > after callbacks will be changing in the next version of Rails.
# > The new return value will reflect the behavior of calling the method
# > after `save` returned (e.g. the opposite of what it returns now). To
# > maintain the current behavior, use `saved_change_to_attribute?` instead.
#
# So, in rails >= 5.2, we must use `saved_change_to_role?`.
if saved_change_to_role?
reset_password!
end
end
end