# Generate Email with Link

**URL:** <https://www.ruby-forum.com/t/generate-email-with-link/174190>\
**Category:** Rails\
**Created:** [August 22, 2009, 3:29am UTC](https://www.ruby-forum.com/t/generate-email-with-link/174190 "2009-08-22T03:29:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [August 22, 2009, 3:29am UTC](https://www.ruby-forum.com/t/generate-email-with-link/174190/1 "2009-08-22T03:29:11Z")

</div>

I am getting confused on how to do this. I want to send a link in an  
email that they can click on. I am confused on whther to use link\_to  
vs url\_for. I would also like to pass in a addional param in the  
link.

Link\_to only generates text not a link.

This the definition in the model ActionMailer.

def emailactivate(reminderinfo)

```
  recipients reminderinfo.email

    subject "Activation Link for your DrugBin Reminders"

        body :reminderinfo => reminderinfo
  content_type "text/html"

```

end

emailactivate.rhtml (is there a difference in putting this as a  
emailactivate.html.erb)

\<%= url\_for(:host =\> APP\_CONFIG[‘settings’][‘domain’], :controller =\>  
‘/user/dashboard’, :action =\> ‘activateemail’, :id =\>  
@reminderinfo.id, :code =\> @reminderinfo.confirmation ) %\>.

\<%= link\_to “Confurm”, :controller =\> ‘/user/dashboard’, :action =\>  
‘activateemail’, :id =\> @reminderinfo.id, :code =\>  
@reminderinfo.confirmation %\>.

---

<div class="post-metadata">

**Author:** ![tashfeen.ekram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3ab097/32.png) [@tashfeen.ekram](https://www.ruby-forum.com/u/tashfeen.ekram)\
**Post date:** [August 22, 2009, 3:59am UTC](https://www.ruby-forum.com/t/generate-email-with-link/174190/2 "2009-08-22T03:59:30Z")

</div>

tashfeen.ekram wrote:

> I am getting confused on how to do this. I want to send a link in an  
> email that they can click on. I am confused on whther to use link\_to  
> vs url\_for. I would also like to pass in a addional param in the  
> link.
> 
> Link\_to only generates text not a link.
> 
> This the definition in the model ActionMailer.
> 
> def emailactivate(reminderinfo)
> 
> ```
> recipients reminderinfo.email
> 
> subject "Activation Link for your DrugBin Reminders"
> 
> body :reminderinfo => reminderinfo
> content_type "text/html"
> 
> ```
> 
> end
> 
> emailactivate.rhtml (is there a difference in putting this as a  
> emailactivate.html.erb)
> 
> \<%= url\_for(:host =\> APP\_CONFIG[‘settings’][‘domain’], :controller =\>  
> ‘/user/dashboard’, :action =\> ‘activateemail’, :id =\>  
> @reminderinfo.id, :code =\> @reminderinfo.confirmation ) %\>.
> 
> \<%= link\_to “Confurm”, :controller =\> ‘/user/dashboard’, :action =\>  
> ‘activateemail’, :id =\> @reminderinfo.id, :code =\>  
> @reminderinfo.confirmation %\>.

I would do this way

In your Action Mailer  
def activateemail(blah,blah)  
@body[:activateurl] =  
“#{SITEURL}/activate/#{classified.activation\_code}”  
end

In Your activateemail.html.erb

Activate using the link: \<%=@activateurl %\>
