Improve the structure so users_with_active_accounts is available on identity
This commit is contained in:
@@ -3,9 +3,5 @@ class My::IdentitiesController < ApplicationController
|
||||
|
||||
def show
|
||||
@identity = Current.identity
|
||||
@active_users = @identity.users.active
|
||||
.joins(:account)
|
||||
.merge(Account.active)
|
||||
.includes(:account)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,6 +28,10 @@ class Identity < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def users_with_active_accounts
|
||||
users.joins(:account).merge(Account.active).includes(:account)
|
||||
end
|
||||
|
||||
private
|
||||
def deactivate_users
|
||||
users.find_each(&:deactivate)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
json.id @identity.id
|
||||
|
||||
json.accounts @active_users do |user|
|
||||
json.accounts @identity.users_with_active_accounts do |user|
|
||||
json.partial! "my/identities/account", account: user.account
|
||||
json.user user, partial: "users/user", as: :user
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user