Created
January 16, 2018 12:51
-
-
Save jdelStrother/7d673acbd52e12fb434433e9f2306bd1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_to_form_value_pairs(params) | |
params.to_query.split("&").map { |component| component.split("=").map { |s| Rack::Utils.unescape(s) } } | |
end | |
params = {post: {title: "foo", category_ids: [1,2,3]}} | |
flatten_to_form_value_pairs(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
["post[category_ids][]", "1"], | |
["post[category_ids][]", "2"], | |
["post[category_ids][]", "3"], | |
["post[title]", "foo"] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment