My site contains user profiles with fields such as hair and eye color.
I use lookup-table type fields with constants in my user model, i.e.
HAIR = %w[shaved black blond brown red grey white bald]
EYES = %w[black brown blue hazel green grey other]
used in my views with collection_select statements to populate dropdowns. I did this with constants to avoid ~ 10 extra joins each time a user profile is viewed.
<%= f.collection_select :eyes, Profile::EYES, :to_s, .....
Values ββare stored as integers in the model, i.e. profile.hair = Profile :: HAIR.index ("red")
Is there any obvious drawback without storing this data in models (for example, Eye model, Hair model) - will this have a big negative impact on the search speed if I want to perform a search based on eye = blue, hair = black for example ?
thank
source
share