Skip to content

Commit feb4058

Browse files
[ci skip] Fix form_with model binding example in guides
This commit fixes an inconsistency in the Form Helpers guide where the example was using Book.find(42) while demonstrating a form for creating a new book. Issue details: - The example shows a form intended for creating a new book (action='/books' with POST method) - However, it was incorrectly binding to an existing book with Book.find(42) - The submit button text is 'Create Book', confirming it's a creation form - The guide explicitly states 'the following form to create a new book' Changes made: - Changed @book = Book.find(42) to @book = Book.new - Updated the example output to show a new book object with nil values This change improves documentation accuracy by ensuring the model object matches the form's purpose and behavior. This helps prevent confusion for developers learning Rails form helpers.
1 parent af6bbef commit feb4058

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

guides/source/form_helpers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ The `form_with` helper has a `:model` option that allows you to bind the form bu
249249
For example, if we have a `@book` model object:
250250

251251
```ruby
252-
@book = Book.find(42)
253-
# => #<Book id: 42, title: "Walden", author: "Henry David Thoreau">
252+
@book = Book.new
253+
# => #<Book id: nil, title: nil, author: nil>
254254
```
255255

256256
And the following form to create a new book:

0 commit comments

Comments
 (0)