How to use my view helpers in my ActionMailer views?

后端 未结 7 1712
清酒与你
清酒与你 2020-11-30 18:17

I want to use the methods I defined in app/helpers/annotations_helper.rb in my ReportMailer views (app/views/report_mailer/usage_report.text.html.erb

相关标签:
7条回答
  • 2020-11-30 18:52

    in my case for Rails4, i do like this:

    # app/mailers/application_mailer.rb
    class ApplicationMailer < ActionMailer::Base
      add_template_helper ApplicationHelper
      ...
    end
    

    and

    # app/mailers/user_mailer.rb
    class AccountMailer < ApplicationMailer
      def some_method(x, y)
      end
    end
    

    so that you do not have to specify add_template_helper everywhere.

    0 讨论(0)
提交回复
热议问题