# Email link not working

**URL:** <https://www.ruby-forum.com/t/email-link-not-working/160634>\
**Category:** Rails\
**Created:** [February 18, 2009, 10:54am UTC](https://www.ruby-forum.com/t/email-link-not-working/160634 "2009-02-18T10:54:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shockmeister](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@Shockmeister](https://www.ruby-forum.com/u/Shockmeister)\
**Post date:** [February 18, 2009, 10:54am UTC](https://www.ruby-forum.com/t/email-link-not-working/160634/1 "2009-02-18T10:54:20Z")

</div>

Hi all,

I’ve integrated a “reset password” facility on the site I’m developing  
allowing the user to reset their password if they forget it. The  
problem I am having is that the link to the reset page is not showing  
up as a hyperlink.

My User\_Mailer looks like this

```
def forgot_password(user)
setup_email(user)
@subject += 'linkITB - Reset Password'
@body[:url] = "http://localhost:3000/user/reset_password/"#

```

{user.reset\_password\_code}"  
end

protected  
def setup\_email(user)  
@recipients = “#{user.email}”  
@from = “removed\_email\_address@domain.invalid”  
@subject = "[linkITB.ie] "  
@sent\_on = Time.now  
@body[:user] = user  
end  
end

My views/ user\_mailer is:

Hi \<%= @user.user\_name %\>,

Your password has been reset.

You can now login by using the following link \<%= @url %\>

Regards,

The linkITB team

---

<div class="post-metadata">

**Author:** ![Shockmeister](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@Shockmeister](https://www.ruby-forum.com/u/Shockmeister)\
**Post date:** [February 18, 2009, 11:20am UTC](https://www.ruby-forum.com/t/email-link-not-working/160634/2 "2009-02-18T11:20:48Z")

</div>

This may be just a typing-error but have you closed the quotations  
after password/ in your mailer model like you have here?

Try setting this in the mailer method:

body :url =\> “[http://localhost:3000/user/reset\_password/#](http://localhost:3000/user/reset_password/#)  
{user.reset\_password\_code}”

and then in the view \<%= link\_to “click here”, @url %\>

Or —

In the view simply specify the full url  
\<%= link\_to ‘click here’, url\_for(:controller =\> ‘users’, :action =\>  
‘reset\_password’, :params=\> (your params)), :host =\> 'your host here)  
%\>

It’s important to specify the host in the mailer views.

Hope this helps

---

<div class="post-metadata">

**Author:** ![Shockmeister](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@Shockmeister](https://www.ruby-forum.com/u/Shockmeister)\
**Post date:** [February 18, 2009, 12:31pm UTC](https://www.ruby-forum.com/t/email-link-not-working/160634/3 "2009-02-18T12:31:56Z")

</div>

Yeah, sorry, that was a typo!! It should have been like you have  
written it.

I’ll try the second implementation and see if that works.

Thanks
