I'm trying to get access to some of my application_helper
methods within my mailer, but nothing seems to be working from these SO posts:
In app/helpers/application_helper.rb
I have the following:
module ApplicationHelper
def get_network_hosts
.. stuff get get a @network_hosts object
end
end
In my mailer at app/mailers/user_notifier.rb
I have the following:
class UserMailer < ActionMailer::Base
default from: "Support <support@me.co>"
add_template_helper(ApplicationHelper)
def trial_notifier(user)
get_network_hosts
@user = user
@total = user.company.subscription.per_device_charge * @network_hosts.count
if @total < 501
@message = "You'd pay #{@total}/month if you converted to full-access now!"
else
@message = "You'd pay #{@total}/month if you converted to full-access now, but we have a better deal for you!"
end
@url = edit_user_registration_url
mail(to: @user.email, subject: 'What's up?')
end
end
In my mailer I've tried all of the suggestions in the above SO posts, but I'm still getting this error:
`NameError: undefined local variable or method `get_network_hosts' for #<UserMailer:0x007fe756c67c18`>
I'm currently using Rails 4.1.7.
So what do I have to actually do to be able to use my application_helper methods within a mailer?