Hi guys, I was thinking aboiut this for a while: If I have nested resource routes, for example /building/1/floor/2/ room/ 3 (building has_many floors and so on), I have to call the room_path method like this: room_path @room.floor.building, @room.floor, @room Isn´t there a better way to handle nested routes with foreign keys, or can I have this method overwritten somewhere? Greets Jonas --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i don''t understand what''s the exact question here, or how you would like this to be simplyfied, but the correct syntax should be: building_floor_room_path(building_id, floor_id, room_id) (at least for rails edge) -- 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 -~----------~----~----~----~------~----~------~--~---
On 30 Nov., 16:50, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> building_floor_room_path(building_id, floor_id, room_id)Oh, of course, you´re right. But what I meant is, that you have to specify every single item in the path of the url. I think that in 80% of the use cases, nested resources are used to indicate parenting in a tree-like data scheme. Perhaps there could be a new option in the map.resource method that could specify the foreign key to be used when generating a path or url, so you just have to write building_floor_room_path(room_id) and the values for building_id and floor_id would be automatically guessed out of the context. Greets Jonas --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---