Rachel Demel
Rachel Demel

Reputation: 41

Adding hyperlink in mail

My requirement is to add a link to mail sent from application developed in Ruby On Rails. Clicking that link in mail need to route user to that particular record in the application.

Can someone please help me with this some sample code.

Upvotes: 2

Views: 6002

Answers (3)

MZaragoza
MZaragoza

Reputation: 10111

If you are starting with Ruby On Rails I would recommend looking at the videos on rails cast. For your email problem you can look at sending-html-email

Also in the email I like to use the link_to helper like this

<%= link_to 'Click Me', something_url(@user.id), %>

I hope that this works. And Happy Coding

Upvotes: 1

Sachin R
Sachin R

Reputation: 11876

In your view template use _url. E.g.:

<%= link_to 'Edit User', edit_user_url(@user) %>

it will return the complete URL.

Upvotes: 7

Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

You can use a simple link_to method in the mail or you could use a simple anchor tag. The latter you would have to build up.

If you need information on how to build links and paths check the rails guides. This has an example on the first section of the guide.

e.g. <%= link_to 'Patient Record', patient_path(@patient) %>

Besides this you need to provide more information if you want more help.

Upvotes: 2

Related Questions