Simple Mailer Switch Not Working

Hello,

Am a newbie to Ruby. Please help me find out why this snippet of code is
failing and picking up the first case always:

class ContactUsMailer < ActionMailer::Base
default :from => “[email protected]

def contact_us_email(name, message, purpose, email)
@name = name
@message = message
@purpose = purpose
@email = email
content_type “text/html”

case @purpose
when ‘android’
mail(:to => ‘[email protected]’, :subject => purpose)
when ‘marketing’
mail(:to => ‘[email protected]’, :cc => ‘[email protected],
[email protected]’, :subject => purpose)
when ‘ios’
mail(:to => ‘[email protected]’, :subject => purpose)
when ‘recruitment’
mail(:to => ‘[email protected]’, :cc => ‘[email protected]’, :subject
=> purpose)
when ‘general’
mail(:to => ‘[email protected]’, :subject => purpose)
else
mail(:to => ‘[email protected]’, :subject => purpose)
end

end
end

Regards !

Can you give a few examples of input? It’s difficult to see where it
goes wrong without following the data you’re entering.

Why are you mixing together instance and local variables? For example,
you’re using @purpose and purpose interchangeably.

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