Skip to content

Commit eed9f25

Browse files
committed
let's get started with PATCH method rather than PUT
1 parent 4b5e424 commit eed9f25

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

guides/source/getting_started.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ it look as follows:
830830
<h1>Editing post</h1>
831831
832832
<%= form_for :post, url: { action: :update, id: @post.id },
833-
method: :put do |f| %>
833+
method: :patch do |f| %>
834834
<% if @post.errors.any? %>
835835
<div id="errorExplanation">
836836
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
@@ -863,7 +863,7 @@ method: :put do |f| %>
863863
This time we point the form to the `update` action, which is not defined yet
864864
but will be very soon.
865865

866-
The `method: :put` option tells Rails that we want this form to be
866+
The `method: :patch` option tells Rails that we want this form to be
867867
submitted via the `PUT` HTTP method which is the HTTP method you're expected to use to
868868
**update** resources according to the REST protocol.
869869

@@ -873,7 +873,7 @@ Next, we need to add the `update` action. The file
873873
`config/routes.rb` will need just one more line:
874874

875875
```ruby
876-
put "posts/:id" => "posts#update"
876+
patch "posts/:id" => "posts#update"
877877
```
878878

879879
And then create the `update` action in `app/controllers/posts_controller.rb`:
@@ -1051,7 +1051,7 @@ called `post_url` and `post_path` available to our application. These are
10511051
precisely the methods that the `form_for` needs when editing a post, and so now
10521052
you'll be able to update posts again.
10531053

1054-
NOTE: The `:as` option is available on the `post`, `put`, `delete` and `match`
1054+
NOTE: The `:as` option is available on the `post`, `patch`, `put`, `delete` and `match`
10551055
routing methods also.
10561056

10571057
### Deleting Posts
@@ -1145,7 +1145,7 @@ get "posts/new"
11451145
post "posts" => "posts#create"
11461146
get "posts/:id" => "posts#show", as: :post
11471147
get "posts/:id/edit" => "posts#edit"
1148-
put "posts/:id" => "posts#update"
1148+
patch "posts/:id" => "posts#update"
11491149
delete "posts/:id" => "posts#destroy"
11501150
```
11511151

0 commit comments

Comments
 (0)