diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index a6fec21ae2c..aba2a891287 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -483,7 +483,7 @@ class AccountsController < ApplicationController end load_course_right_side @account_users = @account.account_users - AccountUser.send(:preload_associations, @account_users, :user) + AccountUser.send(:preload_associations, @account_users, user: :communication_channels) order_hash = {} @account.available_account_roles.each_with_index do |type, idx| order_hash[type] = idx diff --git a/app/models/role_override.rb b/app/models/role_override.rb index ea0bdcefeb3..b7b139edcf8 100644 --- a/app/models/role_override.rb +++ b/app/models/role_override.rb @@ -867,12 +867,12 @@ class RoleOverride < ActiveRecord::Base overrides = @@role_override_chain[permissionless_key] ||= begin role_context.shard.activate do account_ids = context.account_chain_ids(include_site_admin: true).reverse - overrides = RoleOverride.where(:context_id => account_ids, :enrollment_type => generated_permission[:enrollment_type].to_s).group_by(&:permission) + overrides = RoleOverride.where(:context_id => account_ids, :context_type => 'Account', :enrollment_type => generated_permission[:enrollment_type].to_s).group_by(&:permission) # every context has to be represented so that we can't miss role_context below overrides.each_key do |permission| - overrides_by_account = overrides[permission].index_by { |override| [override.context_id, override.context.class.base_class.name] } + overrides_by_account = overrides[permission].index_by(&:context_id) overrides[permission] = account_ids.map do |account_id| - overrides_by_account[[account_id, 'Account']] || RoleOverride.new { |ro| ro.context_id = account_id; ro.context_type = 'Account' } + overrides_by_account[account_id] || RoleOverride.new { |ro| ro.context_id = account_id; ro.context_type = 'Account' } end end overrides