You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to get user role with such code: UserRole.user # => "User" where "User" here is a translation. And its id: UserRole.user_id # => 1. When I fetch the stuff with method te code is more reliable - it's like having constants for each enum, that's why we want to have this functionality in the gem.
In our project we have implemented this with the following module:
Then including it to the enum: UserRole.include(BaseActiveEnum) gives us the requested functionality. I want to share this with you and ask is it reasonable to push this to the gem or not. What do you think? If you reject my proposal anyway the solution may be useful for somebody. But this gem is the most reliable and simplest which I've used as enum, and I believe that this functionality will make it much better.
The text was updated successfully, but these errors were encountered:
It would be great to have ability to get id of enum or name by method. For example, say we have this enum:
I want to get
user
role with such code:UserRole.user # => "User"
where "User" here is a translation. And its id:UserRole.user_id # => 1
. When I fetch the stuff with method te code is more reliable - it's like having constants for each enum, that's why we want to have this functionality in the gem.In our project we have implemented this with the following module:
Then including it to the enum:
UserRole.include(BaseActiveEnum)
gives us the requested functionality. I want to share this with you and ask is it reasonable to push this to the gem or not. What do you think? If you reject my proposal anyway the solution may be useful for somebody. But this gem is the most reliable and simplest which I've used as enum, and I believe that this functionality will make it much better.The text was updated successfully, but these errors were encountered: