Files
once-campfire/app/controllers/accounts_controller.rb
T
Marcello Costagliola f864403c2c List one page of account members at a time
Since administrators were grouped apart from members (b52c318), the account
settings page loads every user to split them and renders all of them. The
lazy next page still starts at the 501st user, so on an account with more
than 500 people, scrolling down lists those users a second time.

Load administrators on their own and page only members, both on the settings
page and on the pages that follow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142qgjggdJ2KDdGk7RF9Xm9
2026-10-05 14:56:22 +02:00

33 lines
730 B
Ruby

class AccountsController < ApplicationController
before_action :ensure_can_administer, only: :update
before_action :set_account
def edit
users = account_users.ordered
@administrators = users.administrator
set_page_and_extract_portion_from users.member, per_page: 500
end
def update
@account.update!(account_params)
redirect_to edit_account_url, notice: "✓"
end
private
def set_account
@account = Current.account
end
def account_params
params.require(:account).permit(:name, :logo, settings: {})
end
def account_users
if Current.user.can_administer?
User.where(status: [ :active, :banned ])
else
User.active
end
end
end