Skip to content

[Views] Pass comment, receipt form and HCB code history ivars to partials as strict locals - #15207

Open
Luke-Oldenburg wants to merge 1 commit into
strict-locals-ivars-6-eventfrom
strict-locals-ivars-7-detail
Open

Luke-Oldenburg wants to merge 1 commit into
strict-locals-ivars-6-eventfrom
strict-locals-ivars-7-detail

Conversation

@Luke-Oldenburg

@Luke-Oldenburg Luke-Oldenburg commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Note

This is one PR in a stack split out of #15191. Review and merge them in order. Each PR's base branch is the PR before it, so its diff shows only its own change.

  1. [Views] Declare strict locals on the remaining partials that take locals #15191 Declare strict locals on the remaining partials that take locals
  2. [Views] Read strict locals instead of local_assigns #15200 Read strict locals instead of local_assigns
  3. [Views] Remove partial ivars that can't simply become locals #15201 Remove partial ivars that can't simply become locals
  4. [Views] Pass layout, login and mailer ivars to partials as strict locals #15202 Pass layout, login and mailer ivars to partials as strict locals
  5. [Views] Pass donation page and FullStory ivars to partials as strict locals #15203 Pass donation page and FullStory ivars to partials as strict locals
  6. [Views] Pass filter values to the filter partials as strict locals #15204 Pass filter values to the filter partials as strict locals
  7. [Views] Pass card, card grant and transfer ivars to partials as strict locals #15205 Pass card, card grant and transfer ivars to partials as strict locals
  8. [Views] Pass event home, settings, invoice and G Suite ivars to partials as strict locals #15206 Pass event home, settings, invoice and G Suite ivars to partials as strict locals
  9. [Views] Pass comment, receipt form and HCB code history ivars to partials as strict locals #15207 Pass comment, receipt form and HCB code history ivars to partials as strict locals ← this PR
  10. [Views] Pass @event and row options through navs and transaction rows as strict locals #15208 Pass @event and row options through navs and transaction rows as strict locals

Summary of the problem

Partials read instance variables that the controller, or the template rendering them, happened to set. Those inputs don't appear in the partial's strict locals declaration from #15191, nothing checks that a caller provides them, and a partial rendered from a page that didn't set the ivar silently gets nil.

This part of the stack turns each ivar a partial reads into a declared local that its callers pass. It was the fourth commit on #15191 (324 files), split by area so each part can be reviewed on its own. With every PR merged, the code is that commit's, except in three partials that got the same object under two names. Those now read the local they already had (in #15205, #15206 and #15208).

Describe your changes

  • Comments: comments/_form takes popover and reads its comment local instead of @comment. Only the comment edit page passed comment: before, and the form read @comment everywhere else, so every caller now passes comment: @comment. comments/_comments, events/settings/_admin and reimbursement/reports/_conversation pass comment and popover along to the form.
  • Receipt uploads: receipts/_form_v3 takes ledger_instance. Every caller passes it, including the three receipt_upload_form_config hashes (in ReceiptsController, hcb_codes/show and ledger/items/show) and ReceiptsController's error stream.
  • HCB codes: hcb_codes/_admin_tools, _transaction_history and _pending_transaction_history take hcb_code.
  • Reimbursements: reimbursement/reports/_actions takes event, including from the turbo streams in ReceiptsController and Reimbursement::ExpensesController. _conversation and _edit_form take report.

How each conversion works

  • Templates, layouts, controllers and mailer templates pass x: @x. A partial in between passes its own local along. Where a partial already had a local holding the same object, it reads that local instead of getting a second copy.
  • A local is required when the body calls a method on it without a nil check. Otherwise it defaults to nil.
  • Every render call passes every new local, including the nil-default ones, so no partial falls back to a default the ivar didn't have.

Testing

🤖 Generated with Claude Code

…ials as strict locals

comments/_form and _comments (and the partials that render the form),
receipts/_form_v3 (ledger_instance), hcb_codes/_admin_tools,
_transaction_history and _pending_transaction_history, and
reimbursement/reports/_actions, _conversation and _edit_form. The three
receipt_upload_form_config hashes, ReceiptsController's error stream
and the reimbursement actions streams pass the new locals too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Luke-Oldenburg
Luke-Oldenburg force-pushed the strict-locals-ivars-6-event branch from e014e61 to fc4e42d Compare October 1, 2026 07:58
@Luke-Oldenburg
Luke-Oldenburg force-pushed the strict-locals-ivars-7-detail branch from 0b5ffb3 to 65b90ed Compare October 1, 2026 07:59

This branch has not been deployed

No deployments
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.

1 participant