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
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: