Skip to content

Instantly share code, notes, and snippets.

@sephraim
Created March 14, 2023 16:33
Show Gist options
  • Save sephraim/79d43433634cf295dd697f49df174c1a to your computer and use it in GitHub Desktop.
Save sephraim/79d43433634cf295dd697f49df174c1a to your computer and use it in GitHub Desktop.
[Format a URL with parameters]
ACTION_LINK_BASE_URL = URI.parse('https://example.com/service.html')
# Action Link URL
#
# @example Example usage
# action_link_url('abc-123-xyz') #=> https://example.com/service.html?id=abc-123-xyz
#
# @param account_id [String]
# @return [String]
def action_link_url(account_id)
action_link_url = ACTION_LINK_BASE_URL
action_link_url.query = URI.encode_www_form(id: account_id)
action_link_url.to_s
end
# Example usage
action_link_url('abc-123-xyz') #=> https://example.com/service.html?id=abc-123-xyz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment