0

I have a helper function to generate email for user as below

module ApplicationHelper
  # Generate unique email for user based on their first and only cat id
  def unique_email_for_user(user)
    "category#{user.cats.first.id}@mywebsite.com"
  end
end

I can call this unique_email_for_user function in my controllers, but not in my Mailer as below

class UserMailer < ApplicationMailer
  # Call application_helpers      
  helper :application

  # match the name to views/mailer/send_reminder.html.erb
  def send_reminder(user)
    @user = user

    # Send email to user
    mail(to: @user.email, reply_to: unique_email_for_user(@user), subject: "My email subject")
  end
end

I get the error as below. I thought adding helper :application to my Mailer would make the necessary connections, No?

enter image description here

Designer
  • 1,061
  • 1
  • 12
  • 26
  • 1
    Does this answer your question? [Access helpers from mailer?](https://stackoverflow.com/questions/4937208/access-helpers-from-mailer) – Sara Fuerst Mar 24 '21 at 13:39

1 Answers1

0

This worked

include ApplicationHelper

instead of

helper :application
Designer
  • 1,061
  • 1
  • 12
  • 26