Hello, I have a problem with nested resources. Ich made following entries in the routes.rb: map.resources :projects do |project| project.resources :iterations do |iteration| iteration.resources :tasks end end when I use link_to: <%= link_to ''Show'', project_iteration_task_path(task.iteration.project, task) %> following is displayed: http://localhost:3000/projects/2/iterations/117/tasks/32 The problem is, that the IDs of iterations and task are interchanged. The real iteration_id = 32 and the real task_id = 117. do sombebody knows a solution or what''s worn with the code? Thanks for every answer! Hermann -- 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 -~----------~----~----~----~------~----~------~--~---
Herman Müller schreef:> Hello, > > I have a problem with nested resources. > > Ich made following entries in the routes.rb: > > map.resources :projects do |project| > project.resources :iterations do |iteration| > iteration.resources :tasks > end > end > > when I use link_to: > > <%= link_to ''Show'', project_iteration_task_path(task.iteration.project, > task) %> > > following is displayed: > > http://localhost:3000/projects/2/iterations/117/tasks/32 > > The problem is, that the IDs of iterations and task are interchanged. > The real iteration_id = 32 and the real task_id = 117. > > do sombebody knows a solution or what''s worn with the code? > > Thanks for every answer! > > Hermann >Hermann You can try the alternative syntax: map.resources :tasks map.resources :iterations, :has_many => [:tasks] map.resources :projects, :has_many => [:iterations] Rudi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
isn''t it safer to use the models to define the relationships? On Nov 1, 4:36 pm, Rudi Indemans <rudi.indem...-d3Be3VBOONU@public.gmane.org> wrote:> Herman Müller schreef: > > > Hello, > > > I have a problem with nested resources. > > > Ich made following entries in the routes.rb: > > > map.resources :projects do |project| > > project.resources :iterations do |iteration| > > iteration.resources :tasks > > end > > end > > > when I use link_to: > > > <%= link_to ''Show'', project_iteration_task_path(task.iteration.project, > > task) %> > > > following is displayed: > > >http://localhost:3000/projects/2/iterations/117/tasks/32 > > > The problem is, that the IDs of iterations and task are interchanged. > > The real iteration_id = 32 and the real task_id = 117. > > > do sombebody knows a solution or what''s worn with the code? > > > Thanks for every answer! > > > Hermann > > Hermann > > You can try the alternative syntax: > > map.resources :tasks > map.resources :iterations, :has_many => [:tasks] > map.resources :projects, :has_many => [:iterations] > > Rudi--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello Rudi, I''ve got an answer form the german forum: The solution from Thomas Baustert, project_iteration_task_path(task.iteration.project, task.iteration, task) and it works fine:-) I only wanted to generate better readable URLS like: http://localhost:3000/projects/2/iterations/36/tasks/140 When I used map.resources :projects, :has_many => [ :iterations] map.resources :iterations, :has_many => [ :tasks] the same URL for tasks looked like this: http://localhost:3000/iterations/36/tasks/140 but there is no conclusion to the project_id. Thank you for your answer Regs, Herman -- 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 -~----------~----~----~----~------~----~------~--~---