[Rails] Re: Modelling Foreign Keys
Steve Koppelman
hatlessnyc at yahoo.com
Sat Apr 1 00:18:41 GMT 2006
In this case, why won't it?
In your user model, you'd say
has_many :posts
and in the post model you'd say
belongs_to :user
and that's all you need for what you describe. What's not working?
Arch Stanton wrote:
> Can someone point me to a reference or tutorial that shows how to map
> foreign key relationships in the model?
>
> For example given:
>
> Users
> id
> name
> email
>
> Posts
> id
> user_id
> title
>
> How do I associate user_id with users.id in the Post and User models?
> has_many and belongs_to don't seem to do it.
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list