aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-05 09:41:45 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-05 10:58:39 +0100
commitaeb48c3b29c25576241a947722ae8db49ed129e4 (patch)
treed213bb483bd302c9a4378444541d4ab7e0833478 /guides
parent40936da37222f3a669505b8e428062c4118ca30e (diff)
downloadrails-aeb48c3b29c25576241a947722ae8db49ed129e4.tar.gz
rails-aeb48c3b29c25576241a947722ae8db49ed129e4.tar.bz2
rails-aeb48c3b29c25576241a947722ae8db49ed129e4.zip
strong parameters example for default values using `fetch`. [ci skip]
Origin: #9534.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/action_controller_overview.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index e65f7e5b18..027f4b785f 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -269,6 +269,18 @@ permitted scalar values allowed), a `hobbies` attribute as an array of
permitted scalar values, and a `family` attribute which is restricted
to having a `name` (any permitted scalar values allowed, too).
+#### More Examples
+
+You want to also use the permitted attributes in the `new`
+action. This raises the problem that you can't use `require` on the
+root-key because normally it does not exist when calling `new`:
+
+```ruby
+# using `fetch` you can supply a default and use
+# the Strong Parameters API from there.
+params.fetch(blog:, {}).permit(:title, :author)
+```
+
#### Outside the Scope of Strong Parameters
The strong parameter API was designed with the most common use cases