Skip to content

Show story idea body as required and humanize its error#1561

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/required-story-label
Open

Show story idea body as required and humanize its error#1561
maebeale wants to merge 1 commit into
mainfrom
maebeale/required-story-label

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Jun 5, 2026

What is the goal of this PR and why is this important?

  • The story idea body field gave submitters no visual cue that it was required.
  • When the body was left blank, the public-facing validation error exposed the internal attribute name "Rhino body" (e.g. "Rhino body can't be blank"), which is confusing to users.

How did you approach the change?

  • Added an optional required: keyword to the rhino_editor helper that switches the label to the required class and appends a red * marker. Defaulted to false so the helper's other ~40 usages (workshops, events, etc.) are unaffected.
  • Passed required: true to the body field on the story idea form.
  • Added activerecord.attributes.story_idea.rhino_body: "Body" to en.yml (matching the existing workshop_variation pattern) so the error reads "Body can't be blank".
  • Added a request spec asserting the invalid-create response says "Body can't be blank" and not "Rhino body".

UI Testing Checklist

  • Story idea form (new): body label shows a red * required marker
  • Submitting the form with a blank body shows "Body can't be blank" (not "Rhino body")

Anything else to add?

  • The shared rhino_editor helper change is scoped behind a parameter, so no other forms change behavior.

The story idea form's body field gave no visual cue it was required, and
its validation error surfaced the internal "Rhino body" attribute name to
public submitters. Mark the label required and relabel the attribute as
"Body" so the error reads naturally.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 5, 2026 15:39

label_tag =
if label.present?
label_content = required ? safe_join([ label, " ", content_tag(:abbr, "*", title: "required", class: "text-red-600 no-underline") ]) : label
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Scoped the required marker behind a keyword (default false) so the ~40 other rhino_editor callers keep the optional styling unchanged.

Comment thread config/locales/en.yml
activerecord:
attributes:
story_idea:
rhino_body: "Body"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Overriding the attribute's human name here makes full_messages (used by the shared errors partial) read "Body can't be blank" instead of leaking the internal rhino_body name. Follows the existing workshop_variation pattern.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Story Idea submission UX by (1) visually indicating that the body field is required and (2) ensuring validation errors display a user-friendly attribute label (“Body”) instead of the internal “Rhino body”.

Changes:

  • Added an optional required: keyword to the shared rhino_editor helper to append a red * marker and apply a required label class.
  • Marked the Story Idea body editor as required in the Story Idea form partial.
  • Added an I18n attribute translation for story_idea.rhino_body and a request spec asserting the humanized error message.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
spec/requests/story_ideas_spec.rb Adds a regression test ensuring the rendered validation error says “Body can’t be blank” and not “Rhino body”.
config/locales/en.yml Adds an attribute translation so Rails full validation messages use “Body” for StoryIdea#rhino_body.
app/views/story_ideas/_form.html.erb Marks the Story Idea body rhino_editor label as required to show a visual cue.
app/helpers/rhino_editor_helper.rb Extends the shared rhino_editor helper with a required: option that adds a required marker and required/optional label class.

Comment on lines 11 to 15
form.label(
base_attribute_name,
label,
class: "block font-medium mb-1 text-gray-700 text optional"
label_content,
class: "block font-medium mb-1 text-gray-700 text #{required ? "required" : "optional"}"
)
@maebeale maebeale marked this pull request as ready for review June 5, 2026 15:57
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