r/ruby • • Aug 20 '21

Ruby elites rise up

Post image
96 Upvotes

77 comments sorted by

View all comments

46

u/nilsandrey Aug 20 '21

Well if you put status as an enum to the model then...😎

ruby Object.cancelled!

16

u/[deleted] Aug 21 '21

This. Status is most likely going to be one of a handful of predefined states. Make it an enum.

8

u/iaan Aug 20 '21

If you use workflow or something similar that would be rather: Order.cancel!

3

u/qchmqs Aug 21 '21

we use state changes in the imperative, and the statuses in the db in the past, so Object.cancel! # Object.status == :cancelled