Two emails are being sent by the code below, both with an identical message-ID, yet I suspect its probably my code.
controller:
@payment.update_attributes(:status => "Confirmed")
Payments Modal:
before_save :check_if_confirmed
before_update :check_if_confirmed
def check_if_confirmed
if status == "Confirmed"
tickets.each do |t|
t.status = "Confirmed"
t.save
end
Emailer.payment(self,user.id,user.full_name, user.email, self.total, self.id).deliver
end
Emailer.rb
def payment(payment, user_id, buyer_name, email = payment.user.email, price, payment_id)
....
mail(:from => "John Smith <john@smith.com>", :to => email, :subject => "Whatever")
The email is being sent once then immediately being sent again. Its a receipt so naturally I need to stop it being sent twice.
Thoughts?