Skip to content

Commit a1259c7

Browse files
authored
Merge pull request rails#52220 from jcbages/patch-1
[ci skip] Update getting_started.md
2 parents 8a45223 + bcca960 commit a1259c7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

guides/source/getting_started.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ Let us also move that new comment section out to its own partial. Again, you
16551655
create a file `app/views/comments/_form.html.erb` containing:
16561656

16571657
```html+erb
1658-
<%= form_with model: [ @article, @article.comments.build ] do |form| %>
1658+
<%= form_with model: [ article, article.comments.build ] do |form| %>
16591659
<p>
16601660
<%= form.label :commenter %><br>
16611661
<%= form.text_field :commenter %>
@@ -1689,17 +1689,14 @@ Then you make the `app/views/articles/show.html.erb` look like the following:
16891689
<%= render @article.comments %>
16901690
16911691
<h2>Add a comment:</h2>
1692-
<%= render 'comments/form' %>
1692+
<%= render "comments/form", article: @article %>
16931693
```
16941694

16951695
The second render just defines the partial template we want to render,
16961696
`comments/form`. Rails is smart enough to spot the forward slash in that
16971697
string and realize that you want to render the `_form.html.erb` file in
16981698
the `app/views/comments` directory.
16991699

1700-
The `@article` object is available to any partials rendered in the view because
1701-
we defined it as an instance variable.
1702-
17031700
### Using Concerns
17041701

17051702
Concerns are a way to make large controllers or models easier to understand and manage. This also has the advantage of reusability when multiple models (or controllers) share the same concerns. Concerns are implemented using modules that contain methods representing a well-defined slice of the functionality that a model or controller is responsible for. In other languages, modules are often known as mixins.

0 commit comments

Comments
 (0)