Most of the material on custom routes and URL generation in Rails
assumes non-nested, non-RESTful routes it seems. Especially for
non-crud actions it is difficult to find good examples for nested
resources.
RESTful tutorials show the basic CRUD routes, and some examples, but
scaffolding doesn’t generate example code that takes these routes into
account.
Non RESTful url creation for example is easy:
:url => { controller: controller_name, :action => action_name, :id => ID
}
generates:
controller_name/action_name/ID
But what about nested and restful resources like this:
parent_controller_name/parent_ID/controller_name/ID;action_name
How do I generate these? Do I have to construct and hard-code the URL
path myself?
Also, the functional controller tests refer to a simple action like
this:
get :new
How do I handle calling the “new” action for a nested resource?