The line
mail to: user.email
Is actually causing your email to send.
Because you are calling this in setup_email, you are actually sending the email AND THEN trying to change the subject and URL after it is sent.
If you ignore the setup method that you have for a second, this is what your code would look like in the order you currently have it:
@subject = "[MY APP] "
@sent_on = Time.now
@user = user
@content_type = "text/html"
mail to: user.email << MAIL IS SENT HERE
@subject += "Password restoration"
@url = url_for :controller => 'user_session', :action => 'reset_password',
:id => user.pw_reset_code, :only_path => true
Update your code to call the mail command last, for example:
def forgot_password(user)
setup_email(user)
@subject += "Password restoration"
@url = url_for :controller => 'user_session', :action => 'reset_password',
:id => user.pw_reset_code, :only_path => true
mail to: user.email
end
protected
def setup_email(user)
@subject = "[MY APP] "
@sent_on = Time.now
@user = user
@content_type = "text/html"
end