[Ruby on Rails] How to Use Helper Methods in ActionMailer Views

Tadashi Shigeoka ·  Thu, February 28, 2013

Here’s a memo on how to use helper methods in Ruby on Rails ActionMailer views.

For example, if you want to use methods defined in ApplicationHelper in app/views/contact_mailer/inquiry.text.haml, use the add_template_helper method as shown below:

class ContactMailer < ActionMailer::Base
  add_template_helper(ApplicationHelper)

  def inquiry(contact)
  end
end

[Reference]:ruby on rails - How to use my view helpers in my ActionMailer views? - Stack Overflow

That’s all from the Gemba.