I have a rails app where I want to send people an email when they sign up. The email has a link to their photos portal so they can get started adding photos, etc..
class MyMailer < ActionMailer::Base
def welcome_email
# ...
link = photos_url # => www.myapp.com/photos
# ...
end
end
The problem is that when I push my code to Heroku and run it live, that link doesn't generate as expected.
The photos_url
returns the URL relative to the localhost
and ends up generating myapp.herokuapp.com/photos
, which is incorrect.
What's even stranger is that if I pause the code at that point with binding.pry
and try to see what photos_url
is returning, it correctly returns www.myapp.com/photos
as expected.
Any thoughts on how to resolve this? I'd hate to have to construct the URL myself from scratch, because that means I have to do it for every environment (localhost
, staging
, production
, etc...)
Thanks!