actionview/lib/action_view/helpers/url_helper.rb
# Creates a TEL anchor link tag to the specified +phone_number+. When the
# link is clicked, the default app to make phone calls is opened and
# prepopulated with the phone number.
#
# If +name+ is not specified, +phone_number+ will be used as the name of
# the link.
#
# A +country_code+ option is supported, which prepends a plus sign and the
# given country code to the linked phone number. For example,
# <tt>country_code: "01"</tt> will prepend <tt>+01</tt> to the linked
# phone number.
#
# Additional HTML attributes for the link can be passed via +html_options+.
#
# ==== Options
# * <tt>:country_code</tt> - Prepends the country code to the phone number
#
# ==== Examples
#   phone_to "1234567890"
#   # => <a href="tel:1234567890">1234567890</a>
#
#   phone_to "1234567890", "Phone me"
#   # => <a href="tel:1234567890">Phone me</a>
#
#   phone_to "1234567890", country_code: "01"
#   # => <a href="tel:+011234567890">1234567890</a>
#
# You can use a block as well if your link target is hard to fit into the name parameter. \ERB example:
#
#   <%= phone_to "1234567890" do %>
#     <strong>Phone me:</strong>
#   <% end %>
#   # => <a href="tel:1234567890">
#          <strong>Phone me:</strong>
#        </a>
Creates a TEL anchor link tag to the specified +phone_number+. When the
link is clicked, the default app to make phone calls is opened and
prepopulated with the phone number.

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

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

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

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







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


Creates a TEL anchor link tag to the specified + phone_number + . When the link is clicked the default app to make phone calls is opened and prepopulated with the phone number . If + name + is not specified + phone_number + will be used as the name of the link . A + country_code + option is supported which prepends a plus sign and the given country code to the linked phone number . For example country_code : " 01 " will prepend + 01 to the linked phone number . Additional HTML attributes for the link can be passed via + html_options + . Options : country_code - Prepends the country code to the phone number You can use a block as well if your link target is hard to fit into the name parameter . \ ERB example .
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
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
Creates a TEL anchor link tag to the specified +phone_number+.
Creates a TEL anchor link tag to the specified + phone_number + .
phone_number
<not_specific>
name
<not_specific>
html_options
<not_specific>
block
<not_specific>