Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def hash_to_params(hash)
  2. hash.keys.inject("") do |qs, key|
  3. qs << "&" unless qs.blank?
  4. qs << if Array === hash[key]
  5. k = CGI.escape(key.to_s)
  6. hash[key].map { |value| "#{k}=" << CGI.escape(value.to_s) }.join("&")
  7. else
  8. CGI.escape(key.to_s) << "=" << CGI.escape(hash[key].to_s)
  9. end
  10. end
  11. end
Add Comment
Please, Sign In to add comment