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

Reopen issue #21 (string id's)? #33

Closed
gene-ressler opened this issue Aug 8, 2013 · 2 comments
Closed

Reopen issue #21 (string id's)? #33

gene-ressler opened this issue Aug 8, 2013 · 2 comments

Comments

@gene-ressler
Copy link

Thanks for this gem. It's a great help in my current project. But I would like to answer @adzap in issue #21 in hopes of restarting the idea. The use case is readability of the underlying database. If I set up an enum for genders, the states or provinces of a country, race/ethnic groups, etc., and the database is used by non-Rails applications, it's much cleaner if the value e.g. New York corresponds to an id that's an understandable abbreviation e.g. 'ny' rather than an integer. This is best practice in database design. I hope you'll consider allowing string values in the next version. Your proposal will work fine: Enum.id(name) and Enum.name(id) . You could retain the bracket notation and raise an exception if the user tries to use it on an enum that has string ids. If I have time I'll take a crack at it in a fork.

@gsmetal
Copy link

gsmetal commented Aug 8, 2013

There is a pull request for this, #28, but it has some problems for now.

@gene-ressler
Copy link
Author

Thanks. Very helpful. Using symbols as id's will be fine if ActiveRecord
will store and load them as corresponding strings in the database. I will
look at this project to see if I can make a contribution.

On Thu, Aug 8, 2013 at 3:04 AM, Sergey Gnuskov notifications@github.comwrote:

There is a pull request for this, #28#28,
but it has some problems for now.


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-22306305
.

Gene Ressler

@adzap adzap closed this as completed Oct 9, 2016
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

No branches or pull requests

3 participants