How does Rails handle many to many relationships?

I’m trying to show a relationship for a user having many tasks. I’ve
noticed the :has_many statement in Rails am not sure what “automagic”
that
creates for you. In .NET, for instance, I would create a bridge table
that
would link user_id to task_id and run queries off of that. For Rails, I
get
a feeling some of this is done for you by using :has_many. Can anyone
explain some of this to me? Or am I crazy and I must build some bridge
table and run queries against it?


Chris S.
[email protected]
http://compiledmonkey.wordpress.com

you need to create a task_user table with columns task_id and user_id

after the associations are set in the models, rails knows how to get the
objects without querying the bridge table. for example, by calling
directly
@user.tasks is possible

On 10/27/06, Chris S. [email protected] wrote:

Chris S.
[email protected]
http://compiledmonkey.wordpress.com


Heri R.
http://sprinj.com

And just leave the “id” columns as defaults for the task and user table?

On 10/27/06, Heri R> [email protected] wrote:

noticed the :has_many statement in Rails am not sure what “automagic” that


Heri R.
http://sprinj.com


Chris S.
[email protected]
http://compiledmonkey.wordpress.com