Skip to content

Conversation

@Luke-Oldenburg
Copy link
Contributor

Summary of the problem

Describe your changes

@Luke-Oldenburg Luke-Oldenburg requested a review from a team December 5, 2025 06:53
<tr>
<td><%= user_mention user %></td>
<%# ideally we do this in all sql instead of rails %>
<td><%= Referral::Link.where(creator: user).sum { |link| link.new_users.where(teenager: true) } %></td>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Referral::Link objects are incorrectly calling the new_users method, which is only defined on Referral::Program.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The view code at app/views/admin/new_teenagers_leaderboard.html.erb:16 attempts to call the new_users method on Referral::Link objects. However, the new_users method is only defined on the Referral::Program model, not on Referral::Link. This will result in a NoMethodError at runtime when the page is rendered, causing the server to crash.

💡 Suggested Fix

Refactor the view code to correctly access the new_users method, likely by accessing the associated Referral::Program object (e.g., link.program.new_users) or by defining a similar method on Referral::Link if intended.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: app/views/admin/new_teenagers_leaderboard.html.erb#L16

Potential issue: The view code at
`app/views/admin/new_teenagers_leaderboard.html.erb:16` attempts to call the `new_users`
method on `Referral::Link` objects. However, the `new_users` method is only defined on
the `Referral::Program` model, not on `Referral::Link`. This will result in a
`NoMethodError` at runtime when the page is rendered, causing the server to crash.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5710073

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants