Comment on Nested Hash Params with Named Routes in Ruby on Rails by roger pack

Mon, 12 Nov 2007 16:34:46 -0800

I did the same thing (1.2.3 still shows this problem). Instead mine was to do something like this

def flatten_interior_hashes_to_singles(params)

out = {}
for key, possible_combined_poorly_value in params
  value = params[key]
  if value.class.ancestors.include? Hash
     for key_inner, value_inner in value
        out["#{key}[#{key_inner}]"] = value_inner # they had better not be 3dd or we're stuck again.  Fix when necessary
      end
   else
   out[key] = value
   end
end
out

end

To avoid having to rewrite ruby code shared among developers. Cheers!

link_to 'whatever', flatten_interior_hashes_to_singles(params).merge({:page => 3})

Note that this doesn't convert them to :symbols (so it's deficient in that way).