Class: CGI

Inherits:
Object show all
Defined in:
lib/core-extensions/cgi_ext.rb

Class Method Summary collapse

Class Method Details

.url_for(url, params = nil) ⇒ Object



4
5
6
7
8
# File 'lib/core-extensions/cgi_ext.rb', line 4

def self.url_for(url, params = nil)
  return url unless params
  params = params.map { |k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&")
  url.index("?") ? "#{url}&#{params}" : "#{url}?#{params}"
end