1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #31568 from bogdanvlviv/update-action_view_overview-guide

Update "Action View Overview" guide [ci skip]
This commit is contained in:
Ryuta Kamizono 2017-12-27 19:22:04 +09:00 committed by GitHub
commit 17ad4eb6fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -807,20 +807,22 @@ The core method of this helper, `form_for`, gives you the ability to create a fo
The HTML generated for this would be: The HTML generated for this would be:
```html ```html
<form action="/people/create" method="post"> <form class="new_person" id="new_person" action="/people" accept-charset="UTF-8" method="post">
<input id="person_first_name" name="person[first_name]" type="text" /> <input name="utf8" type="hidden" value="&#x2713;" />
<input id="person_last_name" name="person[last_name]" type="text" /> <input type="hidden" name="authenticity_token" value="lTuvBzs7ANygT0NFinXj98tfw3Emfm65wwYLbUvoWsK2pngccIQSUorM2C035M9dZswXgWTvKwFS8W5TVblpYw==" />
<input name="commit" type="submit" value="Create" /> <input type="text" name="person[first_name]" id="person_first_name" />
<input type="text" name="person[last_name]" id="person_last_name" />
<input type="submit" name="commit" value="Create" data-disable-with="Create" />
</form> </form>
``` ```
The params object created when this form is submitted would look like: The params object created when this form is submitted would look like:
```ruby ```ruby
{ "action" => "create", "controller" => "people", "person" => { "first_name" => "William", "last_name" => "Smith" } } {"utf8" => "✓", "authenticity_token" => "lTuvBzs7ANygT0NFinXj98tfw3Emfm65wwYLbUvoWsK2pngccIQSUorM2C035M9dZswXgWTvKwFS8W5TVblpYw==", "person" => {"first_name" => "William", "last_name" => "Smith"}, "commit" => "Create", "controller" => "people", "action" => "create"}
``` ```
The params hash has a nested person value, which can therefore be accessed with params[:person] in the controller. The params hash has a nested person value, which can therefore be accessed with `params[:person]` in the controller.
#### check_box #### check_box