Using url_for in ActionMailer templates

David Goodlad
2005-03-06T01:40:41Z

Hi All

I am just adding some basic e-mail notices to my Rails app using
ActionMailer, and have one small issue.  I want to provide a
confirmation URL to users who sign up for an account.  I can obviously
just hardcode the URL and append the confirmation code to it, but I''d
much rather be able to use something like:

url_for(:controller => ''authentication'', :action =>
''confirm'',
:confirmation_code => confirmation_code)

and spit that URL out.  However, it seems taht within the context of
the AM template, no controller is defined, so calling url_for()
results in an error "undefined method `url_for'' for
nil:NilClass"...
The stack trace indicates that it''s finding url_for() in
action_view/base.rb no problem, but I think it''s then trying to call
url_for() on a controller object that isn''t set...

Anyone seen this, and/or come across a solution?

Thanks!
Dave

--
Dave Goodlad
dgoodlad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or
dave-eHfbeeWWzZOw5LPnMra/2Q@public.gmane.org