Repository navigation
Resolves #5611: Render a blank Add Another Item row after a failed partner request - #5743
Open
geographybuff wants to merge 1 commit into
Open
geographybuff wants to merge 1 commit into
geographybuff wants to merge 1 commit into
Conversation
The Add Another Item template rendered _item_request with object: outside locals:. With render partial: ... locals: ..., object: isn't passed as a local, so defined?(object) in the partial was false and fields_for rendered every submitted row into the template. After a failed submit, "Add Another Item" then cloned a copy of the first submitted item. Passing object in locals makes the template hold one blank row again. Resolves rubyforgood#5611 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
geographybuff
marked this pull request as ready for review
October 8, 2026 12:47
dorner
approved these changes
Oct 12, 2026
dorner
left a comment
Collaborator
There was a problem hiding this comment.
Passes tech review. Over to @janeewheatley @ruestitch for QA.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #5611
Description
After a partner request fails validation, "Add Another Item" adds a copy of the first submitted item instead of a blank row.
Cause:
app/views/partners/requests/new.html.erbrendered the template row withrender partial: 'item_request', locals: { ... }, object: .... Withlocals:given, Rails doesn't passobject:as a local namedobject, sodefined?(object)in_item_request.html.erbwas false.form.fields_for :item_requests, nilthen rendered every item request on the form into the<template>: the submitted rows plus the blank one built for the template. The Stimulus controller clones the template's first row, which is the first submitted item.On a fresh form there are no submitted rows yet, so the bug only shows after a failed submit, as the issue describes.
Fix: move
object:intolocals:(one line). The template now holds one blank row, as it does on a fresh form.partners/individuals_requests/new.html.erbuses the shortrender 'path', form: ..., object: ...form, which passesobjectas a local, so it isn't affected.@augustocbx mentioned a fix for this in June; no PR for it was opened, and the issue was auto-unassigned on 2026-08-04.
AI disclosure: prepared with Claude Code (Claude Opus 5.5). It found the cause, wrote the fix and the spec, and ran the specs below.
Type of change
How Has This Been Tested?
spec/requests/partners/requests_spec.rb, under "when there are mixed units / on the same item" (a submit that fails validation with two rows). It parses theaddTemplate<template>and expects exactly onetr, nooption[selected]and an empty quantity.expected: 1, got: 3.bundle exec rspec spec/requests/partners/requests_spec.rbruns 34 examples, 0 failures.erb_linton the view andrubocopon the spec report no offenses.bundle exec rake) and system specs were not run locally; CI will run them.🤖 Generated with Claude Code