aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-09 12:17:32 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-09 12:18:34 +0100
commit1d8b56647859fc0c66149642d83b29e3118d2cb0 (patch)
treea03a405f42373e75349f66114633795415150117 /guides/source
parent1fe5d36e11275a658d4503eda183dcb31b78380a (diff)
downloadrails-1d8b56647859fc0c66149642d83b29e3118d2cb0.tar.gz
rails-1d8b56647859fc0c66149642d83b29e3118d2cb0.tar.bz2
rails-1d8b56647859fc0c66149642d83b29e3118d2cb0.zip
strong parameter example for hashes with integer keys.
This replicates the situation described in https://github.com/rails/strong_parameters/issues/114
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/action_controller_overview.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 5861fc3d54..6b55af53cd 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -290,6 +290,20 @@ parameters:
params.require(:author).permit(:name, books_attributes: [:title, :id, :_destroy])
```
+Hasesh with integer keys are treated differently and you can declare
+the attributes as if they were direct children. You get this kind of
+parameters when you use `accepts_nested_attributes_for` in combination
+with a `has_many` association:
+
+```ruby
+# To whitelist the following data:
+# {"book" => {"title" => "Some Book",
+# "chapters_attributes" => { "1" => {"title" => "First Chapter"},
+# "2" => {"title" => "Second Chapter"}}}}
+
+params.require(:book).permit(:title, chapters_attributes: [:title])
+```
+
#### Outside the Scope of Strong Parameters
The strong parameter API was designed with the most common use cases