Skip to content

Instantly share code, notes, and snippets.

@eltiare
Created January 28, 2009 03:14
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 eltiare/53795 to your computer and use it in GitHub Desktop.
Save eltiare/53795 to your computer and use it in GitHub Desktop.
def urlize_parameters(obj, prefix = '')
case obj
when Hash: obj.map { |k,v| urlize_parameters(v, prefix.blank? ? k : "#{prefix}[#{k}]")}.join('&')
when Array: obj.map { |v| urlize_parameters(v, "#{prefix}[]")}.join('&')
else "#{prefix}=#{obj}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment