Finne Jager wrote in post #968122: > Thank you, I appreciate your help so far, I've been struggling with this > for days now. > >> And Timesheet belongs_to :incident , I hope? > > Correct. > >> See the routing documentation. Once you *do* nest them, you get the >> routes you need for free. >> >> If you don't want to nest them, other solutions are possible, but I'd >> advise nesting if it's feasible for your project. > > Ok, I have nested them like this: > ---------------------------- > resources :incidents do > resources :timesheets > end > ---------------------------- > > And I changed Incidents#create to this: > ---------------------------- > if @incident.save > format.html { redirect_to incident_timesheet_url(@incident) } > ---------------------------- > > Is that the 'free route' you mentioned?
It's one of them, yes. > > On a side note, by changing the resources to nested instead of top > level, it broke my Index page which shows a list of Incidents and their > Timesheets. It pointed out this line of code: > > ---------------------------- > <td><%= link_to 'View Time Sheet', timesheet_path(incident) %></td> > ---------------------------- Right, of course. Run rake routes to see what your routes look like now. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.