views:

88

answers:

1

The new rails routes are great in many aspects, but I am looking for the best way to achieve page caching with pages and formats like I had in rails 2.x and am coming up short

I have many possible desired routes of the basic formulas:

/(bazes/<baz id>/)(foos/<foo id>/)bars/page/<page num>/<format>

Example routes:

/bars/page/1/xml
/foos/1/bars/page/2/html
/bazes/3/foos/1/bars/page/1/json
/bazes/3/bars/page/2/xml

In English:

Give me all bars, page 1, formatted xml
Give me all bars that belong to foo 1, page 2, formatted html
Give me all bars that belong to baz 3 AND foo 1, page 1, formatted json
Give me all bars that belong to baz 3, page 2, formatted xml

I used to be able to do this with a bunch of named routes:

map.baz_foo_bars '/bazes/:baz_id/foos/:foo_id/bars/page/:page/:format', :controller => 'bars', :action => 'formatted_bars'

but this seems wrong in Rails 3 and I think I am missing something that can solve my routing woes efficiently. How can i achieve these routing patterns with Rails 3 routing?

A: 

I was able to get it with a single match statement

match "(/bazess/:baz_id)(/foos/:foo_id)/bars(/page/:page)(/:format)" => "bars#index", :as => :bars
coneybeare