westman2222
westman2222

Reputation: 683

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 %>

Upvotes: 9

Views: 6425

Answers (1)

Sharvy Ahmed
Sharvy Ahmed

Reputation: 7405

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

<%= mail_to @post.source_account, "Email Me" %>

Upvotes: 17

Related Questions