Hello, my current menu is based on acts_as_tree which worked just fine so far but now I need some menu items being shown under more than one parent. Example: menu1 -submenu1 -submenu2 menu2 -submenu1 -submenu3 menu3 -submenu4 -submenu1 I thought about a habtm on the menu model but don''t think that''s a good idea. Does anyone know a proper solution to this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What do you guys think of: has_and_belongs_to_many :parents, :class_name => "Menu", :association_foreign_key => "parent_id", :join_table => "menus_parents" -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 15, 2:03 am, Heinz Strunk <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What do you guys think of: > has_and_belongs_to_many :parents, :class_name => "Menu", > :association_foreign_key => "parent_id", :join_table => "menus_parents"I think it''s astoundingly bad UI to have identical options in more than one place - but that''s just my opinion. Unless your Menu model is exceptionally complicated, is it *really* worth the significant boost in both code and SQL complexity just to support this (hopefully uncommon) edge case? DRY is great, but there''s a point of diminishing (if not negative) returns... As to the technical side of the question, you''d want to use a real join model (with has_many :through). How else could you keep track of the position of the repeated items in each of the parent menus? --Matt Jones -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You''re right, has_many :through is probably a better solution but if you don''t like that approach what would yours look like? Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.