aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVipul A M <vipulnsward@gmail.com>2017-06-19 18:39:49 +0530
committerGitHub <noreply@github.com>2017-06-19 18:39:49 +0530
commit33b596709388cc48d90ab6d1de99d7bd6e85f916 (patch)
tree3976f669507396c3ca128a740fbefe63d7c7cc22
parentb37aa68ff637c4ce1cfd9f6eaec659bc98a1e1b5 (diff)
parent4cb293af5b6da8c1189ffc5355f5ca372b3c1241 (diff)
downloadrails-33b596709388cc48d90ab6d1de99d7bd6e85f916.tar.gz
rails-33b596709388cc48d90ab6d1de99d7bd6e85f916.tar.bz2
rails-33b596709388cc48d90ab6d1de99d7bd6e85f916.zip
Merge pull request #29500 from y-yagi/fix_exmaple_of_parameters_to_query
Fix examples for `AC::Parameters#to_query` [ci skip]
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index cd99e3125f..4a60e2eff2 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -281,6 +281,10 @@ module ActionController
# nationality: "Danish"
# })
# params.to_query
+ # # => ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash
+ #
+ # safe_params = params.permit(:name, :nationality)
+ # safe_params.to_query
# # => "name=David&nationality=Danish"
#
# An optional namespace can be passed to enclose key names:
@@ -289,7 +293,8 @@ module ActionController
# name: "David",
# nationality: "Danish"
# })
- # params.to_query("user")
+ # safe_params = params.permit(:name, :nationality)
+ # safe_params.to_query("user")
# # => "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
#
# The string pairs "key=value" that conform the query string