From 4ac237de74a1ff383a44f6dc04c0e8894633722b Mon Sep 17 00:00:00 2001 From: Dave Aronson Date: Thu, 24 Aug 2023 17:31:46 -0400 Subject: [PATCH] select existing article status if any, in Getting Started Guide -- Fixes #45028 (mostly) (#49010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * select existing article status if any In the Getting Started guide, in the dropdown for an article or comment's status, pre-selecting `public` will make _all_ articles seem `public` even if their status is really something else -- even `nil`. This was reported in issue #45028. Selecting `article.status || 'public'` instead will fix this, in _most_ cases. Pre-existing articles with `nil` status will show up as `public`, but if the form is submitted, they will indeed become `public`. This commit makes that change, and adds text to explain why it is done. * Simplify wording of changes to Getting Started Co-authored-by: Rafael Mendonça França --- guides/source/getting_started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 472eb3018063b..09812baf37097 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1917,12 +1917,12 @@ Our blog has <%= Article.public_count %> articles and counting! <%= link_to "New Article", new_article_path %> ``` -To finish up, we will add a select box to the forms, and let the user select the status when they create a new article or post a new comment. We can also specify the default status as `public`. In `app/views/articles/_form.html.erb`, we can add: +To finish up, we will add a select box to the forms, and let the user select the status when they create a new article or post a new comment. We can also select the status of the object, or a default of `public` if it hasn't been set yet. In `app/views/articles/_form.html.erb`, we can add: ```html+erb
<%= form.label :status %>
- <%= form.select :status, ['public', 'private', 'archived'], selected: 'public' %> + <%= form.select :status, ['public', 'private', 'archived'], selected: article.status || 'public' %>
```