mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ruby 1.9 hash syntax for action controller guide
This commit is contained in:
parent
b1286d3918
commit
bd4470e319
1 changed files with 5 additions and 5 deletions
|
@ -148,7 +148,7 @@ Also, if you've turned on `config.wrap_parameters` in your initializer or callin
|
||||||
And assume that you're sending the data to `CompaniesController`, it would then be wrapped in `:company` key like this:
|
And assume that you're sending the data to `CompaniesController`, it would then be wrapped in `:company` key like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
{ :name => "acme", :address => "123 Carrot Street", :company => { :name => "acme", :address => "123 Carrot Street" } }
|
{ name: "acme", address: "123 Carrot Street", company: { name: "acme", address: "123 Carrot Street" } }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can customize the name of the key or specific parameters you want to wrap by consulting the [API documentation](http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html)
|
You can customize the name of the key or specific parameters you want to wrap by consulting the [API documentation](http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html)
|
||||||
|
@ -246,7 +246,7 @@ To declare that the value in `params` must be an array of permitted
|
||||||
scalar values map the key to an empty array:
|
scalar values map the key to an empty array:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
params.permit(:id => [])
|
params.permit(id: [])
|
||||||
```
|
```
|
||||||
|
|
||||||
To whitelist an entire hash of parameters, the `permit!` method can be
|
To whitelist an entire hash of parameters, the `permit!` method can be
|
||||||
|
@ -266,9 +266,9 @@ mass-assigned.
|
||||||
You can also use permit on nested parameters, like:
|
You can also use permit on nested parameters, like:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
params.permit(:name, {:emails => []},
|
params.permit(:name, { emails: [] },
|
||||||
:friends => [ :name,
|
friends: [ :name,
|
||||||
{ :family => [ :name ], :hobbies => [] }])
|
{ family: [ :name ], hobbies: [] }])
|
||||||
```
|
```
|
||||||
|
|
||||||
This declaration whitelists the `name`, `emails` and `friends`
|
This declaration whitelists the `name`, `emails` and `friends`
|
||||||
|
|
Loading…
Reference in a new issue