Reputation: 4677
I am testing on my localhost. Here is the action_mailer section of my development.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => "[email protected],
:password => ENV['MANDRILL_API_KEY'],
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
and here is the action_mailer file:
def confirm_email(user, school, email)
@user = user
@school = school
@email = email
@url = 'http://example.com/login'
mail(to: @email, subject: 'Please confirm your additional school email.')
end
and here is the view:
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Hello <%= @user.first_name %></h1>
<p>
To confirm your additional school, <%= link_to "click here", verify_other_school_path(@school) %>.
</p>
<p>Thanks and have a great day!</p>
</body>
</html>
The email is working and sending properly. The only problem is that the html generated for the link looks like:
<a href="http://verifyotherschool/4" target="_blank">click here</a>
instead of the way it should:
<a href="http://localhost:3000/verifyotherschool/4" target="_blank">click here</a>
How do I fix this?
Upvotes: 1
Views: 501
Reputation: 44370
remember path
is relative while url
is absolute.
instead
verify_other_school_path(@school)
use
verify_other_school_url(@school)
or
verify_other_school_path(only_path: false, @school)
and read this
Upvotes: 3