# Discourse Gamification - Getting 404 / MissingAttributeError on /leaderboard route

**URL:** https://meta.discourse.org/t/discourse-gamification-getting-404-missingattributeerror-on-leaderboard-route/404855
**Category:** Bug
**Tags:** gamification
**Created:** [June 9, 2026, 3:51pm UTC](https://meta.discourse.org/t/discourse-gamification-getting-404-missingattributeerror-on-leaderboard-route/404855 "2026-06-09T15:51:00Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![glob-canard.4x](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@glob-canard.4x](https://meta.discourse.org/u/glob-canard.4x)
#### Post date: [June 9, 2026, 3:51pm UTC](https://meta.discourse.org/t/discourse-gamification-getting-404-missingattributeerror-on-leaderboard-route/404855/1 "2026-06-09T15:51:00Z")

</div>

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:

```ruby
.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:

```ruby
.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)

---

_[View the full topic](https://meta.discourse.org/t/discourse-gamification-getting-404-missingattributeerror-on-leaderboard-route/404855)._
