Skip to content

Files

Latest commit

 

History

History
31 lines (21 loc) · 538 Bytes

Ruby_String-to-Url.md

File metadata and controls

31 lines (21 loc) · 538 Bytes

Ruby: Convert Strings to Url

URI encode

require 'uri'

URI::encode("Friedrichtraße 123, Berlin, Germany")
#=> "Friedrichtra%C3%9Fe%20123,%20Berlin,%20Germany"
require 'uri'
uri_string = URI::encode("http://localhost:3000/stuff?owner=foo bar+type=video game")

CGI escape

require 'cgi'

CGI.escape('Friedrichtraße 123, Berlin, Germany')
# => "Friedrichtra%C3%9Fe+123%2C+Berlin%2C+Germany"

Rails routes

home_path(:address => 'Friedrichtraße 123, Berlin, Germany')