I'm trying to add "URGENT!" to the beginning of my subject in a email being sent as a confirmation when a form is submitted and the 'Urgent' checkbox is checked.
I basically can't figure out how to find out if the value of the checkbox is "true" or "false".
The checkbox is stored in my Tickets Model under :urgent_reminder column.
Does anyone know what I'm doing wrong here?
Here is my Newticket_Mailer.rb
:
class NewticketMailer < ActionMailer::Base
default from: "ExampleFrom@Email.org"
def urgent
if @ticket.urgent_reminder == true
puts "URGENT!"
else
end
end
def email_subjectCreation
urgent 'Facilities Ticket Created for ' + @ticket.school.name
end
def ticket_creation(ticket)
@ticket = ticket
mail to: @ticket.mailing_list.name, subject: email_subjectCreation, reply_to: @ticket.submitter.full_email
end
end
You're writing to stdout. Try something closer to:
def urgent
'URGENT: ' if @ticket.urgent_reminder
end
def subject
"#{urgent}Facilities Ticket Created for #{@ticket.school.name}"
end
I'd probably make the accessor more Ruby-esque, however:
def urgent
'URGENT: ' if @ticket.urgent?
end