Created user admin scope

This commit is contained in:
Sergei Tsoganov 2023-06-29 10:46:45 +03:00
parent 807c537f67
commit 0ad2fd5a1b
2 changed files with 3 additions and 1 deletions

View file

@ -58,7 +58,7 @@ module Repp
end
def notify_admins
admin_users_emails = User.all.select { |u| u.roles.include? 'admin' }.pluck(:email)
admin_users_emails = User.admin.pluck(:email)
return if admin_users_emails.empty?

View file

@ -3,6 +3,8 @@ class User < ApplicationRecord
has_many :actions, dependent: :restrict_with_exception
scope :admin, -> { where("'admin' = ANY (roles)") }
attr_accessor :phone
self.ignored_columns = %w[legacy_id]