mardi 2 mars 2021

How to make sure that mongoid attribute values are updated in a specific order?

I have an enum enumerize :message_status, in: [:sent, :delivered, :read, :error] in my mongoid class WhatsappLog. I want to make sure that the message status can be updated only in this particular order. "sent" -> "delivered" -> "read". For example, if the message status for a particular document is "delivered", I want to prevent it from being changed to "sent".

Aucun commentaire:

Enregistrer un commentaire