What is the rails way equivalent of mailto: and tel:?

Use mail_to "[email protected]" instead of link_to.

For tel: do link_to @sample.contact, "tel:#{number}"


Use gem tel_to_helper.

tel_to '000-000-0000'
# => <a href="tel:000-000-0000">000-000-0000</a>
tel_to 'My phone number', '000-000-0000'
# => <a href="tel:000-000-0000">My phone number</a>
tel_to '000-000-0000', 'My phone number', target: '_blank'
# => <a href="tel:000-000-0000" target="_blank">My phone number</a>

A simple tel_to helper for tel: links:

def tel_to(phone_number)
  phone_number = number_to_phone(phone_number)
  link_to phone_number, "tel:#{phone_number}"
end

tel_to(8424176704)
# => <a href="tel:842-417-6704">842-417-6704</a>

And the existing mail_to for mailto:

mail_to("Dorian", "[email protected]")
# => "<a href=\"mailto:Dorian\">[email protected]</a>"

Use:

<%= mail_to "[email protected]", 'TEST' %>

more options APIdock mail_to.

For tel_to, there is a GEM, see gem tel_to_helper