This might be a silly question but I'm slightly confuse here :
I have a user model, which has 2 attributes : hair and eyes, that can have a color value.
Instead of referencing the color as a string twice in the hair and eye column of the user table, I'd rather have a separate Color model associated to my User model that my attributes will point at.
I can't figure out how to do that. Do I need has_one, has_many, or polymorphic associations ? How do I set up my User and Colors models ? Do I need to create specific models for hair and eye ?
Here is what I want in a rails console :
u = User.first
u.update_attribute(:hair, Color.find_by_name("blue")
u.update_attribute(:eyes, Color.find_by_name("green")
u.save
u.eyes # green
u.hair # blue
I know this is a pretty basic question, but I really need some help here !
Thanks ;)