Hi, does map.resources accept more than one :has_many ? there seems to be a path helper only for the last one (eg abc_bar_path) map.resources :abc, :has_one => :user, :has_many => :foo, :has_many => :bar if so, is this a bug? (the abc_user_path helper is not overwritten tho) linoj --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Aug-13 22:52 UTC
Re: bug in multiple map.resources :has_many ?
Hi -- On Mon, 13 Aug 2007, linojon wrote:> > Hi, > > does map.resources accept more than one :has_many ? > there seems to be a path helper only for the last one (eg abc_bar_path) > > map.resources :abc, > :has_one => :user, > :has_many => :foo, > :has_many => :bar > > if so, is this a bug? > > (the abc_user_path helper is not overwritten tho)No, it''s not a bug. It''s because of how Ruby hashes work. The last three lines are all key/value pairs in a hash. Since hash keys are unique, you can''t have two :has_many keys, so the last one clobbers the previous one. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
> No, it''s not a bug. It''s because of how Ruby hashes work. The last > three lines are all key/value pairs in a hash. Since hash keys are > unique, you can''t have two :has_many keys, so the last one clobbers > the previous one.So, use an array instead. :has_many => [:foo, :bar] -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
/me slaps forehead On Aug 13, 7:49 pm, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > No, it''s not a bug. It''s because of how Ruby hashes work. The last > > three lines are all key/value pairs in a hash. Since hash keys are > > unique, you can''t have two :has_many keys, so the last one clobbers > > the previous one. > > So, use an array instead. :has_many => [:foo, :bar] > > -- > Rick Olsonhttp://lighthouseapp.comhttp://weblog.techno-weenie.nethttp://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---