Skip to content

Commit 825e350

Browse files
committed
[ci skip] Fix curl response output and use strong parameters in update action.
1 parent 9c9d494 commit 825e350

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

guides/source/layouts_and_rendering.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ X-Runtime: 0.014297
122122
Set-Cookie: _blog_session=...snip...; path=/; HttpOnly
123123
Cache-Control: no-cache
124124

125-
126-
$
125+
$
127126
```
128127

129128
We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for Ajax requests where all you want to send back to the browser is an acknowledgment that the request was completed.
@@ -137,7 +136,7 @@ If you want to render the view that corresponds to a different template within t
137136
```ruby
138137
def update
139138
@book = Book.find(params[:id])
140-
if @book.update(params[:book])
139+
if @book.update(book_params)
141140
redirect_to(@book)
142141
else
143142
render "edit"
@@ -152,7 +151,7 @@ If you prefer, you can use a symbol instead of a string to specify the action to
152151
```ruby
153152
def update
154153
@book = Book.find(params[:id])
155-
if @book.update(params[:book])
154+
if @book.update(book_params)
156155
redirect_to(@book)
157156
else
158157
render :edit

0 commit comments

Comments
 (0)