[Rails] Re: Re: Single Table Mapping

The Barge
Mon, 10 Apr 2006 16:23:49 -0000

Kevin Olbrich wrote:
> When you set up your associations, make the one that you want to have
> the foreign key ''belongs_to'' the one it is associated
with.
>
> In your case,
>
> user_table
>   :id
> end
>
> role_table
>   :user_id
> end
>
> then your user should ''belongs_to :role'' and role should
''has_many
> :users'' or ''has_one :user''
>
> If each user can have one role, but multiple users can have the same
> role, then you need a ''has_many'' for the role.

Hah, I knew it would be something simple.  I typo''d and had the
belongs_to and has_many in the wrong models.  Thanks.