Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

strong parameters example for default values using `fetch`. [ci skip]

Origin: #9534.
  • Loading branch information...
commit aeb48c3b29c25576241a947722ae8db49ed129e4 1 parent 40936da
@senny senny authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 guides/source/
12 guides/source/
@@ -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`:
+# using `fetch` you can supply a default and use
+# the Strong Parameters API from there.
+params.fetch(blog:, {}).permit(:title, :author)
morgoth added a note

Typo here: :blog not blog:

Fixed in 57c516f, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
#### Outside the Scope of Strong Parameters
The strong parameter API was designed with the most common use cases
Please sign in to comment.
Something went wrong with that request. Please try again.