So, I recently decided to enable gamification and immediately ran into an issue where the /leaderboard route was returning a 404 error. The backend had over 800k score records calculated and the permissions checked out, but the page itself wouldn’t load.
Checking the server logs showed:
ActiveModel::MissingAttributeError (missing attribute 'admin' for User)
While digging through the plugin code, I noticed in lib/discourse_gamification/leaderboard_cached_view.rb that the user query uses a specific .select string to pull columns for the leaderboard:
.select(
"users.id, users.name, users.username, users.uploaded_avatar_id, p.total_score, p.position",
)
Because users.admin and users.moderator aren’t included in that query, the instantiated user objects don’t have those fields available. It looks like (?) somewhere further down the line during serialization or core layout rendering, a staff check is being triggered on those users, causing Rails to throw the MissingAttributeError and fall back to a 404.
I manually edited that file to include users.admin and users.moderator in the .select block:
.select(
"users.id, users.name, users.username, users.uploaded_avatar_id, users.admin, users.moderator, p.total_score, p.position",
)
After restarting the app container, the leaderboard started loading perfectly.
I’m guessing this is a bug (?) or have I completely overthought/overlooked something?
The site is currently on v2026.6.0-latest (47a830330f)