Hi all. I''ve the following scenario: users id cars id name One user has many cars, but I need to always edit cars table (add more models, edit actual models, etc.). So, I''m think about use another table: cars_users id_user id_car This means an HABTM relationship, right? Is this the rigth approach to my problem? One user doesn''t belongs to a car (in my point of view). What should I do? Best regards and sorry my poor English, -- Davi Vidal -- E-mail: davividal-UiHwsRqXctc1RhZgQKG/ig@public.gmane.org MSN : davividal-uAjRD0nVeow@public.gmane.org GTalk : davividal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Skype : davi vidal YIM : davi_vidal ICQ : 138815296 --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
hey Davi. You might want to look into "has_many :through =>" and use a join table for the relationship. best. mike On Jun 11, 2008, at 11:24 AM, Davi Vidal wrote:> > > Hi all. > > I''ve the following scenario: > > users > id > > cars > id > name > > One user has many cars, but I need to always edit cars table (add > more > models, edit actual models, etc.). So, I''m think about use another > table: > > cars_users > id_user > id_car > > This means an HABTM relationship, right? Is this the rigth approach > to my > problem? One user doesn''t belongs to a car (in my point of view). > > > What should I do? > > Best regards and sorry my poor English, > -- > Davi Vidal > -- > E-mail: davividal-UiHwsRqXctc1RhZgQKG/ig@public.gmane.org > MSN : davividal-uAjRD0nVeow@public.gmane.org > GTalk : davividal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > Skype : davi vidal > YIM : davi_vidal > ICQ : 138815296 > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
> > users > id > > cars > id > name > > One user has many cars, but I need to always edit cars table (add more > models, edit actual models, etc.). So, I''m think about use another table: > > cars_users > id_user > id_car > > This means an HABTM relationship, right? Is this the rigth approach to my > problem? One user doesn''t belongs to a car (in my point of view). >Yes, your secong version would be a habtm. But what for? If one user can have several cars, but a car only belongs to a single user there is no need for that. (This has nothing to do with editing) The simple question: Can a car have several users? If yes, you''ll need habtm, otherwise it''s not necessary. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---