Skip to content

Instantly share code, notes, and snippets.

@kamarcum kamarcum/nonsense.rb Secret
Last active Aug 29, 2015

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

kamarcum commented Apr 21, 2014

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
You can’t perform that action at this time.