module ActionView::Helpers::UrlHelper

def phone_to(phone_number, name = nil, html_options = {}, &block)


Phone me:
# =>
<% end %>
Phone me:
<%= phone_to "1234567890" do %>

You can use a block as well if your link target is hard to fit into the name parameter. \ERB example:

# =>
1234567890
phone_to "1234567890", country_code: "01"

# => Phone me
phone_to "1234567890", "Phone me"

# => 1234567890
phone_to "1234567890"
==== Examples

* :country_code - Prepends the country code to the phone number
==== Options

Additional HTML attributes for the link can be passed via +html_options+.

phone number.
country_code: "01" will prepend +01 to the linked
given country code to the linked phone number. For example,
A +country_code+ option is supported, which prepends a plus sign and the

the link.
If +name+ is not specified, +phone_number+ will be used as the name of

prepopulated with the phone number.
link is clicked, the default app to make phone calls is opened and
Creates a TEL anchor link tag to the specified +phone_number+. When the
def phone_to(phone_number, name = nil, html_options = {}, &block)
  html_options, name = name, nil if name.is_a?(Hash)
  html_options = (html_options || {}).stringify_keys
  country_code = html_options.delete("country_code").presence
  country_code = country_code.nil? ? "" : "+#{ERB::Util.url_encode(country_code)}"
  encoded_phone_number = ERB::Util.url_encode(phone_number)
  html_options["href"] = "tel:#{country_code}#{encoded_phone_number}"
  content_tag("a", name || phone_number, html_options, &block)
end