5

I have a helper defined in my application_helper.rb that I would like to use in my mailer view, but just doing

<%= helper_method(param) %>

in the mailer_view.html.erb file gets me an 'undefined method' error.

Is there another way to do this? I would hate to have to put the same helper somewhere else.

Thanks.

Colin Wu
  • 611
  • 7
  • 25
  • Does this answer your question? [Access helpers from mailer?](https://stackoverflow.com/questions/4937208/access-helpers-from-mailer) – idmean Aug 05 '20 at 12:19

1 Answers1

10

Apparently this has been asked before (who knew!) :). The answer is to include

helper ApplicationHelper

in the example_mailer.rb file:

class ExampleMailer < ApplicationMailer
  helper ApplicationHelper
  ...
end
Colin Wu
  • 611
  • 7
  • 25