nested routes + scaffolding
I'm trying to understand nested routes at the moment.
I generated these three models with the scaffold generator:
Because all models belong together I defined the following nested routes:
class Category < ActiveRecord::Base
class Topic < ActiveRecord::Base
class Post < ActiveRecord::Base
With these routes I have to change most of the generated views and controllers. For example instead of topic_path(params[:id]) it has to be category_topic_path(params[:category_id], params[:id]) and so on.
map.resources :categories do |categories|
categories.resources :topics do |topics|
Is there any way to make this easier and less error prone?
I know it's not a good idea to have to deeply nested routes. But otherwise I don't know how to get all needed information. To create a topic for example I need the category_id ...
Thanks for any advices.