Blog posts for Ruby, Ruby on rails and Linux.

Go back to all blogs

Using Helper methods in the ActionMailer views

Kapil Raj Nakhwa2013-Oct-22
Many of the times we need to use some helpers inside our mailer views to show or format some information. But the helper methods are not available inside the ActionMailer Views By default. So what can we do about it ?
It turns out we can use our helper methods quite easily within our ActionMailer views by adding the templates in our Mailer Classes like following.
class MyMailer < ActionMailer::Base
  add_template_helper(MyAwesomeHelper)

  ...
end

Tags: rails4,helper methods,actionmailer,views,ruby-tricks

Go back to all blogs
Never miss a post on new ruby and rails tips