diff --git a/app/controllers/admin/api/accounts_controller.rb b/app/controllers/admin/api/accounts_controller.rb index efb95fcd9a..5c6da16b02 100644 --- a/app/controllers/admin/api/accounts_controller.rb +++ b/app/controllers/admin/api/accounts_controller.rb @@ -22,7 +22,7 @@ def index def find buyer_account = find_buyer_account authorize! :read, buyer_account - respond_with(to_present(buyer_account)) + respond_with(preload_to_present(buyer_account)) end # Account Read @@ -30,7 +30,7 @@ def find def show authorize! :read, buyer_account - respond_with(to_present(buyer_account)) + respond_with(preload_to_present(buyer_account)) end # Account Update @@ -38,7 +38,7 @@ def show def update authorize! :update, buyer_account - to_present(buyer_account) + preload_to_present(buyer_account) buyer_account.vat_rate = params[:vat_rate].to_f if params[:vat_rate] buyer_account.settings.attributes = billing_params @@ -73,7 +73,7 @@ def change_plan def approve authorize! :approve, buyer_account - to_present buyer_account + preload_to_present buyer_account buyer_account.approve respond_with(buyer_account) @@ -84,7 +84,7 @@ def approve def reject authorize! :reject, buyer_account - to_present buyer_account + preload_to_present buyer_account buyer_account.reject respond_with(buyer_account) @@ -95,7 +95,7 @@ def reject def make_pending authorize! :update, buyer_account - to_present buyer_account + preload_to_present buyer_account buyer_account.make_pending respond_with(buyer_account) @@ -115,7 +115,7 @@ def buyer_account @buyer_account ||= buyer_accounts.find(params[:id]) end - def to_present(accounts) + def preload_to_present(accounts) # ActiveRecord::Associations::Preloader.new(records: Array(accounts), associations: [:annotations, {bought_plans: %i[original]}]).call # Rails 7.x ActiveRecord::Associations::Preloader.new.preload(Array(accounts), [:annotations, {bought_plans: %i[original]}]) accounts