Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alt_name_to_ids method for enum value to string mapping #4

Conversation

aldinrozario
Copy link
Contributor

@aldinrozario aldinrozario commented Jul 5, 2024

This PR adds a new class method to rich_enums, which can be used for mapping enum values to string values.

eg:

class User < ApplicationRecord
rich_enum role: { admin: [1, 'ROLE001'], user: [2, 'ROLE101'] }
end

User.role_alt_name_to_ids
=> {"ROLE001"=>1, "ROLE101"=>2}

@harunkumars harunkumars merged commit 5ef7213 into betacraft:main Jul 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants