Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:52:01+00:00 2026-06-10T01:52:01+00:00

Two emails are being sent by the code below, both with an identical message-ID,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:52:02+00:00Added an answer on June 10, 2026 at 1:52 am

    before_save :check_if_confirmed is fired every time the record is being saved (even if its created)

    before_update :check_if_confirmed is fired when record was already created and the data is just updated.

    You are using the wrong callbacks, that are firing mail delivering twice. before_save should be enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My controller action is being executed twice. Fiddler shows two requests and responses, and
In Apple's Contacts app, if you go to a contact that has two emails
I have two tables user and email. One user can have multiple emails so
This is being sent via Ajax. Here's the JS: $.ajax({ url: objCommon.ajax, type: 'POST',
Below are two pics of my app, the first showing the total area where
Using Symfony1, how could I validate one of two fields is being filled in
Hope you can help me with this its probably really simple but I'm pretty
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
I have a table called notification , with two columns: provider email The values
I have two templates for my HTML email: one for bigger screens, and one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.