phone_to
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (-38)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
phone_to(phone_number, name = nil, html_options = {}, &block)
public
Creates a TEL anchor link tag to the specified phone_number, which is also used as the name of the link unless name is specified. Additional HTML attributes for the link can be passed in html_options.
When clicked, the default app to make calls is opened, and it is prepopulated with the passed phone number and optional country_code value.
phone_to has an optional country_code option which automatically adds the country code as well as the + sign in the phone numer that gets prepopulated, for example if +country_code: β01β+ ++01+ will be prepended to the phone numer, by passing special keys to html_options.
Options
-
:country_code - Prepends the country code to the number
Examples
phone_to "1234567890" # => <a href="tel:1234567890">1234567890</a> phone_to "1234567890", "Phone me" # => <a href="tel:134567890">Phone me</a> phone_to "1234567890", "Phone me", country_code: "01" # => <a href="tel:+015155555785">Phone me</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>