mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
update getting_started guide to reduce confusion [ci skip] (#37750)
Add a yellow "NOTE" block to see if the guide looks better.
This commit is contained in:
parent
97b0833458
commit
9024fa31e2
1 changed files with 11 additions and 2 deletions
|
@ -1129,8 +1129,9 @@ you attempt to do just that on the new article form
|
||||||
We've covered the "CR" part of CRUD. Now let's focus on the "U" part, updating
|
We've covered the "CR" part of CRUD. Now let's focus on the "U" part, updating
|
||||||
articles.
|
articles.
|
||||||
|
|
||||||
The first step we'll take is adding an `edit` action to the `ArticlesController`,
|
The first step we'll take is adding an `edit` action to the
|
||||||
generally between the `new` and `create` actions, as shown:
|
`ArticlesController`, generally between the `new` and `create`
|
||||||
|
actions, as shown:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
def new
|
def new
|
||||||
|
@ -1152,6 +1153,10 @@ def create
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
NOTE: We're using `edit` to render a view. For the actual
|
||||||
|
saving of the changes to the Article, we'll add an `update` action later.
|
||||||
|
|
||||||
|
|
||||||
The view will contain a form similar to the one we used when creating
|
The view will contain a form similar to the one we used when creating
|
||||||
new articles. Create a file called `app/views/articles/edit.html.erb` and make
|
new articles. Create a file called `app/views/articles/edit.html.erb` and make
|
||||||
it look as follows:
|
it look as follows:
|
||||||
|
@ -1214,6 +1219,10 @@ Next, we need to create the `update` action in
|
||||||
Add it between the `create` action and the `private` method:
|
Add it between the `create` action and the `private` method:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
def edit
|
||||||
|
@article = Article.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@article = Article.new(article_params)
|
@article = Article.new(article_params)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue