ActionView::Helpers::NumberHelper
def number_to_phone(number, options = {})

Description

Formats the number as a phone number.

Arguments

Changing a value updates the ERB and HTML.

Formats the number as a phone number using ActiveSupport::NumberHelper. A non-numeric value ("abc") is used as is, without delimiters, instead of raising an error. Returns nil for nil.
options= {}
true wraps the area code in ( ). If the number has fewer than 8 digits, returns it as is, without delimiters.
" "
The string to use as the delimiter instead of -. The given string is escaped. Escaped even if it is html_safe.
1
Prepends +, the given number and the delimiter.
555
Appends the given number, preceded by x with a space on each side.
/(\d{2})(\d{4})(\d{4})$/
The regular expression that decides where the delimiters go. Puts the delimiter between its three matched groups, and if area_code is true, wraps the first one in ( ).
true raises InvalidNumberError when the number argument is not a number.
Options not listed here do not become HTML attributes. number_to_phone does not use number format translations, so :locale does not change the format.

ERB

Changes from the previous output: Added Removed Changed


          

HTML