Can somebody help me to convert the following array to a hash with the following format?
Array
[["0", {"checkbox_2"=>"on"}], ["2", {"checkbox_1"=>"on"}]]
Hash
search=>{"checkbox_2"=>"on", "checkbox_1"=>"on"}
xs = [["0", {"checkbox_2"=>"on"}], ["2", {"checkbox_1"=>"on"}]]
search = {:search => xs.map { |n, h| h }.inject(:merge)}
# {:search=>{"checkbox_2"=>"on", "checkbox_1"=>"on"}}
{ :search => xs.map(&:last).inject(:merge) }?arr = [["0", {"checkbox_2"=>"on"}], ["2", {"checkbox_1"=>"on"}]]
hash = Hash[arr.flatten.select{|e| e.is_a? Hash}.collect{|e| e.to_a.flatten}]
=> {"checkbox_2"=>"on", "checkbox_1"=>"on"}