Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format as link to email address, ruby on rails

The <%= @post.source_account %> is an email address. I want this to display as a link that says "Email Me" and when click it will open the users mail client

 <% if @post.source_account.present? %>
          <h4>Email Seller: <small> <%= @post.source_account %><br></h4>
          <% end %>
like image 628
westman2222 Avatar asked Mar 28 '15 18:03

westman2222


1 Answers

You can use mail_to, which creates a mailto link tag to the specified email address:

<%= mail_to @post.source_account, "Email Me" %>
like image 99
Sharvy Ahmed Avatar answered Nov 10 '22 02:11

Sharvy Ahmed