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 Stewart compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://compiledmonkey.wordpress.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 Stewart <compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 Stewart > compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > http://compiledmonkey.wordpress.com > > >-- Heri R. http://sprinj.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
And just leave the "id" columns as defaults for the task and user table? On 10/27/06, Heri R> <heri.yamiyama-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 Stewart <compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 Stewart > > compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > http://compiledmonkey.wordpress.com > > > > > > > -- > Heri R. > http://sprinj.com > > >-- Chris Stewart compiledmonkey-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://compiledmonkey.wordpress.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---