I'm having a hard time figuring out the "Rails Way" to add a email confirmation URL to a mailer.
I'm opting not to do this purely RESTfully because, well, it's difficult with text email because they can't PUT
requests.
so here's my routes.rb: get 'confirm/:id' => 'Confirmations#confirm'
and in my mailer I'd like to put email_confirm_url(@user.email_token)
where I want the URL to occur.
I created a helper:
#app/helpers/confirmations_helper.rb
module ConfirmationsHelper
def email_confirm_url(token)
"/confirm/#{token}"
end
end
this all works, sort of, except when I call email_confirm_url(@user.email_token)
…
I literally get: "/confirm/abcdefg…
"
When what I want is: http://myhostname/confirm/abcdefg…
Or in development: http://localhost:3000/confirm/abcdefg…
How can I make my URL helper behave more like the built in <resource>_path
and <resource>_url
helpers in Rails? though realistically I suppose I really only need _url
.
#Edit: I have this in my environment config:
#config/environments/development.rb
...
config.action_mailer.default_url_options = { :host => "localhost:3000" }