Ruby on Rails 3 actionmailer subject line issue

554 views Asked by At

I really need some help and I've spent the last few days how to figured out what went wrong on this little thing.

My spec: Rails 3.2.8 Ruby 1.9.3 Actionmailer 3.2.8

I can send email without problem but the subject line is not working. No matter what value I put under :subject and the email subject always is the method name which is "commentadded" in this case.

For example:

class Notification < ActionMailer::Base 
default from: "[email protected]"


def commentadded (users,ccusers, project) 
    @msgsub = "Comment of #{project.title} has been created"           
    @users = users.collect(&:email).join(",")          
    @ccusers = ccusers.collect(&:email).join(",") 
    @project= project
    mail(:to => @users, :cc => @ccusers, :subject => @msgsub )  
    mail.deliver

end

end

I have tried hardcode the subject line :subject => "testing subject" but the subject still is "commentadded"

And when I set the default subject line on the top of the file (default subject: "XXXXX"), then it works but that's not the way i wanted since I have different kind of email templates.

I appreciate any helps.

Thanks,

Wing

1

There are 1 answers

2
davidrac On

You should avoid using the name @subject. Change the variable name and things should work...

See here