`add_template_helper`方法在Rails6.1中似乎不起作用

将我的项目更新到 Rails 6.1 后,我收到此错误:

NoMethodError:
  undefined method `add_template_helper' for ApplicationMailer:Class

在文档中似乎没有被弃用。

回答

因此,显然,此方法在此提交中被删除而没有弃用警告:

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

因此,解决此问题的方法是替换:

class MyMailer < ApplicationMailer
  add_template_helper MyHelper

和:

class MyMailer < ApplicationMailer
  helper MyHelper

  • Wow, I can't believe I had this exact same issue on the same day. This worked for me - thanks!

以上是`add_template_helper`方法在Rails6.1中似乎不起作用的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>