ActionView::Helpers::UrlHelper
def sms_to(phone_number, name = nil, html_options = {}, &block)

Description

Creates an <a> whose href starts with sms:.

Arguments

Changing a value updates the ERB and HTML.

Used as the part of the href after sms:. Percent-encodes spaces and punctuation other than - and a few others (%2B, %20, etc.). If the name argument is omitted, this string is used as the content of the <a>.
= nil
The content of the <a>, escaped. Defaults to the phone_number argument. A hash is treated as html_options, so you can leave out this argument and pass only html_options.
html_options= {}
"1"
Prepends + and the given value to the phone number. A value that already starts with + ("+1") gives +%2B1. An empty string adds nothing.
"Hello & bye"
Adds ?&body= with the given value after the ;. Percent-encodes spaces, &, etc. in the value (%20, %26). An empty string adds nothing.
"https://example.com"
Ignored. The href is always the sms: URL built from the phone_number argument.
Common options

Rails handles these options the same way in every helper. Options the HTML spec does not allow on the <a>, and ones this site considers rarely used, are not listed here.

Shared by all helpers

{active: true, hidden: false}
A hash gives the keys whose values are not false or nil, joined with spaces. An array gives its elements joined with spaces, after removing nil, false and empty strings (including whitespace-only strings).
{controller: "tags", tags_suggestions_value: ["ruby", "rails"]}
A hash adds data-* attributes, with _ in the keys converted to -. Array and hash values are converted to JSON strings.
{describedby: ["name_help", "name_error"], invalid: false}
Like :data, adds aria-* attributes. Array values are joined with spaces, leaving out nil and empty strings (nothing is added if none remain). For a hash value, the keys whose values are not false or nil are joined with spaces.
Any other html_options become HTML attributes of the <a>; those with a nil value are left out. Unlike link_to, method and remote also become HTML attributes as is. The href always has ; after the phone number.

ERB

Changes from the previous output: Added Removed Changed


          

HTML


          

Preview