New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action Controller guide edits for grammar and clarity #18459
Action Controller guide edits for grammar and clarity #18459
Conversation
|
||
Also, if you've turned on `config.wrap_parameters` in your initializer or calling `wrap_parameters` in your controller, you can safely omit the root element in the JSON parameter. The parameters will be cloned and wrapped in the key according to your controller's name by default. So the above parameter can be written as: | ||
Also, if you've turned on `config.wrap_parameters` in your initializer or called `wrap_parameters` in your controller, you can safely omit the root element in the JSON parameter. In this case, by default, the parameters will be cloned and wrapped with a key chosen based on your controller's name. So the above JSON POST can be written as: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't say "by default," since you're explicitly overriding the default behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will fix shortly.
Thanks @georgeclaghorn, I agree with both of those comments and have updated the PR. |
👍 You'll also want to squash your commits. |
✔️ Done! |
NOTE: Values such as `[nil]` or `[nil, nil, ...]` in `params` are replaced | ||
with `[]` for security reasons by default. See [Security Guide](security.html#unsafe-query-generation) | ||
for more information. | ||
NOTE: Values such as `[nil]` or `[nil, nil, ...]` in `params` are replaced with `[]` for security reasons by default. See [Security Guide](security.html#unsafe-query-generation) for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this change please ? Even though this seems inconsistent throughout the file, we are slowly wrapping new additions around 80 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I'll revert this.
Thanks @robin850, I've incorporated your suggestions and squashed. |
|
||
```json | ||
{ "name": "acme", "address": "123 Carrot Street" } | ||
``` | ||
|
||
And assume that you're sending the data to `CompaniesController`, it would then be wrapped in `:company` key like this: | ||
And, assuming that you're sending the data to `CompaniesController`, it would then be wrapped with a `:company` key like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about "within the :company
key" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, "it would then be wrapped within the :company
key"? Sure, I can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I've rebased and addressed all comments. Is this ready to merge? |
Other than that, everything LGTM! |
@@ -131,11 +131,11 @@ To send a hash you include the key name inside the brackets: | |||
|
|||
When this form is submitted, the value of `params[:client]` will be `{ "name" => "Acme", "phone" => "12345", "address" => { "postcode" => "12345", "city" => "Carrot City" } }`. Note the nested hash in `params[:client][:address]`. | |||
|
|||
Note that the `params` hash is actually an instance of `ActiveSupport::HashWithIndifferentAccess`, which acts like a hash but lets you use symbols and strings interchangeably as keys. | |||
The `params` hash is actually an instance of `ActiveSupport::HashWithIndifferentAccess`, which acts like a Hash but lets you use symbols and strings interchangeably as keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true true anymore. params
is an instance of ActionController::Parameters
. Maybe we should not talk about which class it inherit but only that symbols and strings are interchangeable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point. Changed to
The `params` object acts like a Hash, but lets you use symbols and strings interchangeably as keys.
Additional changes made. Thanks @trosborn & @rafaelfranca! |
Action Controller guide edits for grammar and clarity
Awesome work! |
Thanks! |
This PR updates the Action Controller guide with some minor grammar and clarity improvements.