Forum: Ruby on Rails email link not working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
32edf22df6932b252d7be5a1b9b766c9?d=identicon&s=25 Shockmeister (Guest)
on 2009-02-18 10:54
(Received via mailing list)
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        = "admin@linkITB.ie"
      @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
648a71a35ce6e4a1c5cd63451a2a20df?d=identicon&s=25 Gavin (Guest)
on 2009-02-18 11:20
(Received via mailing list)
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
32edf22df6932b252d7be5a1b9b766c9?d=identicon&s=25 Shockmeister (Guest)
on 2009-02-18 12:31
(Received via mailing list)
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
This topic is locked and can not be replied to.