3 ms·
And the disadvantage is that you need to look at the code to understand the data. Some things change infrequently enough for DB native to be the better solutio
by petepete 7y ago
And the disadvantage is that you need to look at the code to understand the data.
Some things change infrequently enough for DB native to be the better solution.
- evsasse 7y agoA nice "trick" is to declare your enum column on the database as a string, and your enum in the code as a hash with string values. So you can have self-explained data saved onto the database, and all the niceties Rails gives you from the enum. enum object_type: { review: "review", purchase: "purchase", offer: "offer", reward: "reward" } # OR enum action: TYPES.map { |type| [type.to_sym, type.to_s] }.to_h
- rietta 7y agoNice! I've done #1, but #2 is a neat trick.