This question is related to: How to use my view helpers in my ActionMailer views?
I have a UserMailer.rb
and I am trying to add TextHelper
so I can use pluralize(@x, "x")
. I've tried a few things but none seem to work:
class UserMailer < ActionMailer::Base
1. helper :text
2. add_template_helper(TextHelper)
3. application.rb
config.to_prepare do
ActionMailer::Base.helper "text"
end
Do you know how I can get pluralize to work in my e-mails? Thanks!
That's how it worked for me:
class UserMailer < ActionMailer::Base
include ActionView::Helpers::TextHelper
def notify(alarms)
mail(:subject => "#{alarms.size} new #{pluralize(alarms.size, 'alarm')}", ...
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With