From 672e28c692152924c0a08c9fe0ebe5e9e3c3ef96 Mon Sep 17 00:00:00 2001 From: Aldric Giacomoni Date: Tue, 17 Feb 2015 14:50:51 -0500 Subject: [PATCH 1/2] make `nested parameters` of README more readable --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b7b582..15db864 100644 --- a/README.md +++ b/README.md @@ -63,10 +63,31 @@ This will mark the `:log_entry` parameters hash and any subhash of it permitted. You can also use permit on nested parameters, like: ``` ruby -params.permit(:name, {:emails => []}, :friends => [ :name, { :family => [ :name ], :hobbies => [] }]) +params.permit(:name, + { + :emails => [] + }, + { + :friends => [ + :name, + { + :family => [ :name ], + :hobbies => [] + } + ] + }) ``` -This declaration whitelists the `name`, `emails` and `friends` attributes. It is expected that `emails` will be an array of permitted scalar values and that `friends` will be an array of resources with specific attributes : they should have a `name` attribute (any 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). +**Here is what this does** + +It whitelists the `name`, `emails` and `friends` attributes. + +It is expected that `emails` will be an array of permitted scalar values. + +It is expected that `friends` will be an array of resources with specific attributes: +* a `name` attribute (any permitted scalar values allowed) +* a `hobbies` attribute as an array of permitted scalar values +* a `family` attribute which is restricted to having a `name` (any permitted scalar values allowed, too). Thanks to Nick Kallen for the permit idea! From ff6659f727450d8554d6250a12cc79f36e3aab63 Mon Sep 17 00:00:00 2001 From: Aldric Giacomoni Date: Wed, 18 Feb 2015 15:26:23 -0500 Subject: [PATCH 2/2] Bullet points are easier to scan visually --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 15db864..589eddb 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,12 @@ params.permit(:name, **Here is what this does** -It whitelists the `name`, `emails` and `friends` attributes. - -It is expected that `emails` will be an array of permitted scalar values. - -It is expected that `friends` will be an array of resources with specific attributes: -* a `name` attribute (any permitted scalar values allowed) -* a `hobbies` attribute as an array of permitted scalar values -* a `family` attribute which is restricted to having a `name` (any permitted scalar values allowed, too). +* It whitelists the `name`, `emails` and `friends` attributes. +* It is expected that `emails` will be an array of permitted scalar values. +* It is expected that `friends` will be an array of resources with specific attributes: + * a `name` attribute (any permitted scalar values allowed) + * a `hobbies` attribute as an array of permitted scalar values + * a `family` attribute which is restricted to having a `name` (any permitted scalar values allowed, too). Thanks to Nick Kallen for the permit idea!