Files
once-campfire/app/controllers/accounts/users_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

27 lines
621 B
Ruby

class Accounts::UsersController < ApplicationController
before_action :ensure_can_administer, :set_user, only: %i[ update destroy ]
def index
set_page_and_extract_portion_from User.active.ordered.member, per_page: 500
end
def update
@user.update(role_params)
redirect_to edit_account_url
end
def destroy
@user.deactivate
redirect_to edit_account_url
end
private
def set_user
@user = User.active.find(params[:user_id] || params[:id])
end
def role_params
{ role: params.require(:user)[:role].presence_in(%w[ member administrator ]) || "member" }
end
end