Email link not working


#1

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


#2

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/#
{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


#3

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