G5 / storext

Add type-casting and other features on top of ActiveRecord::Store.store_accessor
MIT License
210 stars 55 forks source link

Any support for responding to Enums? #43

Closed henrymzhao closed 7 years ago

henrymzhao commented 7 years ago

Hello,

Apologies this is not a "bug", but github doesn't really provide another way to ask a question.

I'm trying to use this gem to handle preference settings for my project, and I'm trying to get each "setting" to correspond to a defined enum. I have defined my settings as an integer like: foo_setting Integer, default: 0, and I'd like the integer to go through a pre-defined enum and return a param, instead of a single integer.

Is this possible with this gem? I'm transitioning from defining each setting as a separate column in the database, which then linked to an enum list.

Thanks for your time.

ramontayag commented 7 years ago

I searched for "enum ActiveRecord store" and came up with nothing. I suppose it could be done but I fail to see why one would want to move to enum to a serialized column.

1.You'll lose performance on the scopes you get with enum.

  1. It seems like you'll always want to define the possible values anyway, and that means touching the code (and add a new column)
henrymzhao commented 7 years ago

Thank you for your input, I've switched to a String type instead, which works a lot better, and makes integration with the old code a lot easier.