Skip to content

Instantly share code, notes, and snippets.

@kamarcum
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamarcum/01e8ba283ebfb39877f9 to your computer and use it in GitHub Desktop.
Save kamarcum/01e8ba283ebfb39877f9 to your computer and use it in GitHub Desktop.
rack parsed_nested_query nonsense
irb(main):001:0> require 'rack'
=> true
irb(main):002:0> query = "filter%5Bsubspecialties%5B%5D%5D=Abdominal+Radiology&filter%5Bemployee_type%5D=All"
=> "filter%5Bsubspecialties%5B%5D%5D=Abdominal+Radiology&filter%5Bemployee_type%5D=All"
irb(main):003:0> Rack::Utils
=> Rack::Utils
irb(main):005:0> Rack::Utils.parse_nested_query query
=> {"filter"=>{"subspecialties"=>[nil], "employee_type"=>"All"}}
irb(main):006:0> query2 = "filter%5Bsubspecialties%5D%5B%5D=Abdominal+Radiology&filter%5Bemployee_type%5D=All" => "filter%5Bsubspecialties%5D%5B%5D=Abdominal+Radiology&filter%5Bemployee_type%5D=All"
irb(main):007:0> Rack::Utils.parse_nested_query query2
=> {"filter"=>{"subspecialties"=>["Abdominal Radiology"], "employee_type"=>"All"}}
@kamarcum
Copy link
Author

I had filter[subspecialties[]]
but needed filter[subspecialties][]

🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment