class User < ApplicationRecord include Clearance::User def self.update_board_members(new_emails) where(active: true).each do |user| if !new_emails.include?(user.email) user.update(active: false) # TODO: notify board member of deactivation end end new_emails.each do |email| user = User.find_by(email: email) if user if !user.active? # TODO: notify board member of activation user.update(active: true, password: SecureRandom.hex(32)) end else # TODO: notify board member of activation User.create(email: email, password: SecureRandom.hex(32)) end end end end