Face it: to the newcomer, Rails routing is strange and mysterious. It
took me a while get the hang of it, so I thought I'd share some info
(and a couple of handy techniques) for those who are new to Rails.
Here, assume we have Users and Reports, and that one User "has many"
Reports. Normally, that will be expressed in your model files (but
that's another topic!) -- but right now we're focused on making an entry
in config/routes.rb to express how incoming URLs map to your
In this example, we're using RESTful routing to create "shallow nested
routes" to express that a User :has_many Reports. So we create an entry
in config/routes.rb like this:
map.resources :users, :has_many => :reports, :shallow => true