From 1dc9e1ce7f7e51491ce186b7da2965951d73307d Mon Sep 17 00:00:00 2001 From: corwinkelly Date: Tue, 22 Oct 2013 16:11:56 -0400 Subject: Update workaround for "Outside the Scope of Strong Parameters" The previous example of how to permit a hash of unknown keys used .tap, but had the side effect of logging an "Unpermitted parameters" message despite being a successful workaround. The proposed workaround is ever so slightly better, imo, because it won't result in an "Unpermitted parameters" message being logged. --- guides/source/action_controller_overview.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index cd4a1a0792..3d8e438b3a 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -328,9 +328,7 @@ the job done: ```ruby def product_params - params.require(:product).permit(:name).tap do |whitelisted| - whitelisted[:data] = params[:product][:data] - end + params.require(:product).permit(:name, { data: params[:product][:data].keys }) end ``` -- cgit v1.2.3 From 872b3c91b3d6bd5b418463cb92ecc05bce39649d Mon Sep 17 00:00:00 2001 From: corwinkelly Date: Wed, 23 Oct 2013 07:47:15 -0400 Subject: Fix undefined method error for NilClass Add .try to prevent undefined method error for NilClass. --- guides/source/action_controller_overview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 3d8e438b3a..82a23b3dc0 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -328,7 +328,7 @@ the job done: ```ruby def product_params - params.require(:product).permit(:name, { data: params[:product][:data].keys }) + params.require(:product).permit(:name, { data: params[:product][:data].try(:keys) }) end ``` -- cgit v1.2.3