aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-11-08 09:58:58 +0100
committerXavier Noria <fxn@hashref.com>2016-11-11 23:31:50 +0100
commite86524c0c5a26ceec92895c830d1355ae47a7034 (patch)
tree35bed8b96f65678e5da98af61262dc0f4368bd91 /guides
parenta5e933410dcbf097c5f180ec7ce9b3567a9e3514 (diff)
downloadrails-e86524c0c5a26ceec92895c830d1355ae47a7034.tar.gz
rails-e86524c0c5a26ceec92895c830d1355ae47a7034.tar.bz2
rails-e86524c0c5a26ceec92895c830d1355ae47a7034.zip
adds support for arbitrary hashes in strong parameters
Diffstat (limited to 'guides')
-rw-r--r--guides/source/action_controller_overview.md18
1 files changed, 15 insertions, 3 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 7b1138c7d4..40eb838d32 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -258,6 +258,17 @@ scalar values, map the key to an empty array:
params.permit(id: [])
```
+Sometimes it is not possible or convenient to declare the valid keys of
+a hash parameter or its internal structure. Just map to an empty hash:
+
+```ruby
+params.permit(preferences: {})
+```
+
+but be careful because this opens the door to arbitrary input. In this
+case, `permit` ensures values in the returned structure are permitted
+scalars and filters out anything else.
+
To whitelist an entire hash of parameters, the `permit!` method can be
used:
@@ -265,9 +276,10 @@ used:
params.require(:log_entry).permit!
```
-This will mark the `:log_entry` parameters hash and any sub-hash of it as
-permitted. Extreme care should be taken when using `permit!`, as it
-will allow all current and future model attributes to be mass-assigned.
+This marks the `:log_entry` parameters hash and any sub-hash of it as
+permitted and does not check for permitted scalars, anything is accepted.
+Extreme care should be taken when using `permit!`, as it will allow all current
+and future model attributes to be mass-assigned.
#### Nested Parameters