ruby - How to get key name from a enum value in Rails? -


i have enum in model corresponds column in database.

the enum looks like:

enum efficency: { high: 0, medium: 1, low: 2 } 

how can key value

for example, have value 0, need fetch value high.

any appreciated.

model.efficiencies.key(0) # => 'high' 

replace model actual name of model.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -