From 2d9b77da86edd58c3e1e66aec3cbfd9c832068f5 Mon Sep 17 00:00:00 2001 From: maebeale Date: Thu, 4 Jun 2026 20:36:18 -0400 Subject: [PATCH] Allow clearing story author on edit form The author select used Rails' prompt: option, which only renders the placeholder when no value is selected. On an existing story the author is already set, so no blank option existed and the field could not be returned to 'Select an author'. Switch to include_blank: so the blank option always renders, matching the new-story behavior. Fixes #1517 Co-Authored-By: Claude Opus 4.8 --- app/views/stories/_form.html.erb | 2 +- spec/views/stories/edit.html.erb_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb index 15fd78dd5..c34b6375e 100644 --- a/app/views/stories/_form.html.erb +++ b/app/views/stories/_form.html.erb @@ -275,7 +275,7 @@
<%= f.input :created_by_id, collection: @users.map { |u| [ u.full_name_with_email, u.id ] }, - prompt: "Select an author", + include_blank: "Select an author", label: (f.object.created_by&.person ? ( link_to "Story author", person_path(f.object.created_by.person), diff --git a/spec/views/stories/edit.html.erb_spec.rb b/spec/views/stories/edit.html.erb_spec.rb index 270f6b077..c674619ef 100644 --- a/spec/views/stories/edit.html.erb_spec.rb +++ b/spec/views/stories/edit.html.erb_spec.rb @@ -36,6 +36,14 @@ end end + it "renders a blank author option so an already-set author can be cleared" do + render + + assert_select "select[name=?]", "story[created_by_id]" do + assert_select "option[value=?]", "", text: "Select an author" + end + end + it "does not render the Website button when website_url is nil" do story.update(website_url: nil) assign(:story, story.decorate)