hi every one, i''m new to ruby on rails.so, need some help. my project is that a user can add friends to his profile where friends are users themselves. i thought of creating two tables one for users and other for user_friends.i don''t know how to relate these two tables so that they serve my purpose. any suggestions plz. thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am also new but I think you just need to add to Users model: has_and_belongs_to_many :users. On Jun 28, 8:06 am, gow <gowtham.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi every one, > > i''m new to ruby on rails.so, need some help. > > my project is that a user can add friends to his profile where friends > are users themselves. > > i thought of creating two tables one for users and other for > user_friends.i don''t know how to relate these two tables so that they > serve my purpose. > > any suggestions plz. > > thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
check out self referential associations - it is exactly what you are looking for. the problem with doing has_and_belongs_to_many :users, is that you will still need a join table that ''holds'' these associated records. give it time, it looks daunting at first, but it works. :) a couple links: i worked with this * http://blog.hasmanythrough.com/2006/4/21/self-referential-through although it is clearly outdated, and there are probably better things out there. i also googled for a sec, and found * http://lists.rubyonrails.org/pipermail/rails/2006-February/021193.html * http://blog.dnite.org/2007/6/8/howto-has_many_friends (same plugin) * http://blog.dnite.org/2007/3/14/has_many_friends-released anyway .. check out google for self_referential; that''s the way to go. hope this helps! shai -- Posted via http://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
thank u russian for the reply. i did add has_and_belongs_to_many :users. to User model. On Jun 28, 11:49 am, RussianGeek <igoro1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am also new but I think you just need to add to Users model: > has_and_belongs_to_many :users. > > On Jun 28, 8:06 am, gow <gowtham.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hi every one, > > > i''m new to ruby on rails.so, need some help. > > > my project is that a user can add friends to his profile where friends > > are users themselves. > > > i thought of creating two tables one for users and other for > > user_friends.i don''t know how to relate these two tables so that they > > serve my purpose. > > > any suggestions plz. > > > thanks in advance.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thank u shai the urls u send were really helpful.i got great deal of relevant stuff from those links. On Jun 28, 12:51 pm, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> check out self referential associations - it is exactly what you are > looking for. > the problem with doing has_and_belongs_to_many :users, is that you will > still need a join table that ''holds'' these associated records. > > give it time, it looks daunting at first, but it works. :) > a couple links: > > i worked with this > * http://blog.hasmanythrough.com/2006/4/21/self-referential-through > although it is clearly outdated, and there are probably better things > out there. > i also googled for a sec, and found > *http://lists.rubyonrails.org/pipermail/rails/2006-February/021193.html > * http://blog.dnite.org/2007/6/8/howto-has_many_friends > (same plugin) > * http://blog.dnite.org/2007/3/14/has_many_friends-released > > anyway .. check out google for self_referential; that''s the way to go. > hope this helps! > > shai > > -- > Posted viahttp://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---