In my Rails app I have a fairly standard has_many relationship between two entities. A Foo
has zero or more Bars
; a Bar
belongs to exactly
Rails' shallow nesting gives us the best of both worlds: it lets us have Foo-specific routes where it makes sense (create, new, index) and Bar-only routes otherwise (show, edit, update, destroy).
Unfortunately, the new routing DSL in Rails 3 (which I'm using) does not support shallow routing yet (as of Beta 3). It appears to be in the works but it's not functional for today.
However, you can fake it by mapping the resource twice, once nested and once shallow:
resources :foo do
resources :bar, :only => [:index, :new, :create]
end
resources :bar, :only => [:show, :edit, :update, :destroy]
This will tide me over until the :shallow option is up and running again.