Possible bug in actionmailer

I have the following code to send out email notifications. The view
can vary for each call to signup_confirmation, so I’m setting
template_root on each call in order to do that. It works for a while,
but after a few days it will start using a value of signup_path that
was used in a previous call. In other words, Notifier.template_root =
signup path does not actually set Notifier.template_root to the value
of signup_path. Instead it seems to be setting template_root to the
view that was most recently modified.

For example, lets say signup_confirmation has been called 50 times
with 5 different values for signup_path. Then all of the sudden it
breaks, displaying the wrong view. Then from that point on, the view
that it displays is whatever view has the most recent file
modification date. Restarting the application fixes the problem.
Also, this is running under scgi, and development versus production
mode doesn’t seem to make any difference.

class Notifier < ActionMailer::Base

def
signup_confirmation(merchant,affiliate,password,login_url,signup_path)
Notifier.template_root = signup_path

Email header info MUST be added here

 @recipients = affiliate.email,merchant.email
 if merchant.signup_confirmation_from.empty?
   @from = merchant.email
 else
   @from = merchant.signup_confirmation_from
 end
 if merchant.signup_confirmation_subject.empty?
   @subject = "Welcome to #{merchant.name}"
 else
   @subject = merchant.signup_confirmation_subject
 end
 if merchant.signup_confirmation_ctype.empty?
   @content_type = "text/html"
 else
   @content_type = merchant.signup_confirmation_ctype
 end

Email body substitutions go here

@body[“template_root”] = Notifier.template_root
@body[“signup_path”] =signup_path
@body[“merchant_name”] = merchant.name
@body[“merchant_support_email”] = merchant.signup_confirmation_from
@body[“name”] = affiliate.name
@body[“email”] = affiliate.email
@body[“address1”] = affiliate.address1
@body[“address2”] = affiliate.address2
@body[“city”] = affiliate.city
@body[“state”] = affiliate.state
@body[“zip”] = affiliate.zip
@body[“country”] = affiliate.country
@body[“phone”] = affiliate.phone
@body[“fax”] = affiliate.fax
@body[“username”] = affiliate.username
@body[“password”] = password
@body[“login_url”] = login_url
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs