Since ActionMailer Email Templates are not first-class citizens in the Rails template world, you can’t automagically access your custom helpers (including ApplicationHelper).
Someday ActionMailer may go on a pilgrimage and return fully enlightened. In the meantime, here is how you can get at those pesky helpers and continue following the DRY principle to your heart’s content.
First, Add something like this to the bottom of you helper file (such as application_helper.rb):
class HelperWrapper
class << self
include ApplicationHelper
end
end
Of course, you could put it in another file and then require it in, but that would be more annoying.
Then, just require your helper from within your email template like so:
<% require File.join(RAILS_ROOT, "app", "helpers", "application_helper") %>
Now, you can access your helpers as class methods on HelperWrapper (e.b., HelperWrapper.wassssup(true))
Since ActionMailer Email Templates are not first-class citizens in the Rails template world, you can’t automagically access your custom helpers (including ApplicationHelper).
Someday ActionMailer may go on a pilgrimage and return fully enlightened. In the meantime, here is how you can get at those pesky helpers and continue following the DRY principle to your heart’s content.
First, Add something like this to the bottom of you helper file (such as application_helper.rb):
class HelperWrapper
class << self
include ApplicationHelper
end
end
Of course, you could put it in another file and then require it in, but that would be more annoying.
Then, just require your helper from within your email template like so:
<% require File.join(RAILS_ROOT, "app", "helpers", "application_helper") %>
Now, you can access your helpers as class methods on HelperWrapper (e.b., HelperWrapper.wassssup(true))