[Ruby] ApplicationHelper methods in ActionMailer templates
Ken Harris
kengruven at gmail.com
Thu Jan 3 17:40:43 PST 2008
(Ruby 1.8.6, Rails 1.2.5.)
How do you use/get ApplicationHelper methods in an ActionMailer
template?
The comment above ApplicationHelper says it's included in all
templates. I've got a method in ApplicationHelper that wraps url_for
(for a specific case), and I'm using in my normal Rails views, and
everything is good.
I want to put this link in an email, too, so I tried just using the
helper in my ActionMailer template. No good: apparently
ApplicationHelper is only included in templates called by
ActionController or something. No problem -- I'll just include
ApplicationHelper where I need it by hand, right?
Well, after mucking around for a while, I can't seem to figure it out.
The method doesn't seem to exist even when explicitly imported, or the
url_for call is expecting something which ActionMailer::Base doesn't
have, or something worse.
The obvious things didn't work, and the more obscure solutions I try
to come up with, the weirder the error messages get. That's usually a
sign I'm missing something simple and correct.
Has anybody done this before? What stupidly simple thing am I
missing?
thanks,
- Ken
More information about the Ruby
mailing list