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

Mon, 12 Nov 2007 16:38:08 -0800

oops I meant

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

used like

link_to 'something', flatten_interior_hashes_to_singles(params).merge({:new_param => new_setting})
or what have you.