-
Notifications
You must be signed in to change notification settings - Fork 160
Open
Labels
Description
Let's say we need to send an email after every state transition and the requirement is to include in this email subject: "Changed From: #{previous_state} TO: #{current_state}"
The way I currently do it:
after_transition do |model, transition|
previous_state = model.transitions.where(most_recent: false).last.to_state
StateTransitionNotifier.new(previous_state, model.current_state).perform
end
Why not having the "from" state scoped here? It would not be correct doing this on before_transition callback as something could go wrong, right? Even though, we could rely on validations, using before_transition would be semantically incorrect.
stevebissett and dmitry