I need to get the string name of the state of an enumeration by an integer value, and I do it as follows
Order.states.find{|x| x[1] == data['stateId']}
Does anyone know a better way to do this?
enum state: {
created: 0,
cancelled: 100,
complete: 10,
}
source
share