jeudi 25 mai 2017

AASM does not trigger before callbacks on calling the same state/event again

I have following state machine - which is NOT sending the mails again after I called the send_mail method once. It works only the first time?!

aasm do
  state :created, initial: true
  state :mail_sent do
    before do
      Mailer.send_mail().deliver
    end
  end

  event :send_mail do
    transitions from: [:created, :mail_sent], to: :mail_sent
  end
end

How is the best practice to do this?

Aucun commentaire:

Enregistrer un commentaire