Module: Dorsale::Users::Active

Defined in:
app/models/dorsale/users/active.rb

Class Method Summary collapse

Class Method Details

.included(user_model) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/dorsale/users/active.rb', line 2

def self.included(user_model)
  user_model.class_eval do
    validates :is_active, inclusion: {in: [true, false]}

    def initialize(*)
      super
      self.is_active = true if is_active.nil?
    end

    def active_for_authentication?
      super && self.is_active?
    end

    def inactive_message
      I18n.t("messages.users.inactive")
    end
  end
end