Ruby on Rails Friday, July 30, 2010

On Jul 29, 12:25 pm, bingo bob <li...@ruby-forum.com> wrote:
> Appreciate this is a path well travelled probably.
>
> What's the best way of to deal with gender.
>
> i.e. a Person is either Male or Female (generally and fot my purposes
> I'll stick with that rule).
>
> So is it best to go Person with an attribute gender, or, I guess it's
> best to do something like this - the rails way?
>
> Person
>   belongs_to: gender
>
> Gender
>   has_many: people
>
> Sorry if this is such an obvious question just want to do it right.

This is a great example of a case where normalization is doing it
wrong. Unless you're somehow expecting additional genders to be added,
this sort of a solution is overkill and pretty much only nets you
additional database overhead. Using an attribute should suffice...

--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment