How to URL encode a string in Ruby
1 minsYou can use Ruby’s CGI::Escape method to escape or encode a string to URL encoded format. Let’s see an example of URL encoding in Ruby -
URL encoding a string in Ruby
require 'cgi'
url_encoded_string = CGI.escape("Coder's@Ruby")
puts url_encoded_string
# Output
Coder%27s%40Ruby