[Rails] Re: Re: Single Table Mapping

The Barge
Mon, 10 Apr 2006 15:45:25 -0000

Yeah that''s how I ended up fixing the problem, but has_one requires a
user_id field in the ROLES table.  This means for each user in the
database there is a row in the ROLES table.  Since this is one-to-one it
would be better (IMHO) to have a single ROLE_ID in the USERS table, and
only have one row per role in the ROLES table.  This would mean just one
additional smallint column the the USERS table and the ROLES table would
be nice and small and wouldn''t grow (unless I added more roles).

Tom Mornini wrote:
> You need to use has_one instead of has_many
>
> --
> -- Tom Mornini