43

After updating my project to Rails 6.1 I get this error:

NoMethodError:
  undefined method `add_template_helper' for ApplicationMailer:Class

In the documentation does not seem to be deprecated.

Daniel
  • 4,051
  • 2
  • 28
  • 46

1 Answers1

120

So, apparently, this method was deleted without deprecation warning in this commit:

https://github.com/rails/rails/commit/cb3b37b37975ceb1d38bec9f02305ff5c14ba8e9

So, the fix for this issue is to replace:

class MyMailer < ApplicationMailer
  add_template_helper MyHelper

With:

class MyMailer < ApplicationMailer
  helper MyHelper
Daniel
  • 4,051
  • 2
  • 28
  • 46
  • 2
    Wow, I can't believe I had this exact same issue on the same day. This worked for me - thanks! – jayp Jan 01 '21 at 23:12
  • It is not working for me: undefined method `format_currency' for # – Anas Ansari Apr 28 '22 at 08:18
  • 1
    Note, you can also do `helper :my` and it will automatically include `MyHelper` (notice that you don't include `_helper` suffix when doing it this way). – Joshua Pinter Aug 25 '22 at 16:43