Skip to content
This repository has been archived by the owner on Aug 17, 2017. It is now read-only.

Readme documentation on using accepts_nested_attribute_for with Strong Parameters #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ This declaration whitelists the `name`, `emails` and `friends` attributes. It is

Thanks to Nick Kallen for the permit idea!

In order to use `accepts_nested_attribute_for` with Strong Parameters, you will need to specify which nested attributes should be whitelisted. It's mandatory to specify the nested attributes that should be whitelisted. If you use `permit` with just the key that points to the nested attributes hash, it will return an empty hash.

``` ruby
params.require(:person).permit(:name, :age, pets_attributes: [ :name, :category ])
```

## Handling of Unpermitted Keys

By default parameter keys that are not explicitly permitted will be logged in the development and test environment. In other environments these parameters will simply be filtered out and ignored.
Expand Down