I have a enum in my Model that corresponds to column in the database.
The enum looks like:
enum efficency: { High: 0, Medium: 1, Low: 2 }
How can I get the key from the value
For example, i have the value 0, i need to fetch the value High.
Any help would be appreciated.
Model.efficiencies.key(0) # => 'High'
Replace Model
with the actual name of your model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With