Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def hash_to_params(hash)
- hash.keys.inject("") do |qs, key|
- qs << "&" unless qs.blank?
- qs << if Array === hash[key]
- k = CGI.escape(key.to_s)
- hash[key].map { |value| "#{k}=" << CGI.escape(value.to_s) }.join("&")
- else
- CGI.escape(key.to_s) << "=" << CGI.escape(hash[key].to_s)
- end
- end
- end
Add Comment
Please, Sign In to add comment