I’ve already gone through a similar loop (and as it happens, have a
plugin that I’m currently running through its paces) for ‘canned
map.report_on :sales do |sales|
sales.today #=> /sales/today calls today()
sales.for_year ‘during/:year’ #=> /sales/during/:year calls for_year()
It’s pretty trivial to do this sort of thing as long as you work
within the limitations of the route mapper.
1 the only bit of context passed into your blocks is path_prefix and
this means that you don’t have access to a :controller option when
your pages() method (or my report_on() method) is called. And
implicitly passing the :controller in the scope would be interpreted
as manually overriding the controller for other methods like
2 for map.resources, the path_prefix given to your block is for the
member and not the collection.
3 there’s little point trying to overcome #2 because by the time your
block executes it’s too late to define any /pages urls for the
collection. As in /posts/pages will be picked up by the route for
I’ve experimented with a hack or two that tried to address #2 by
changing with_options to pass more than one OptionMerger but
ultimately it’s pointless because of #3.
Wayne, I’d be happy to let you see my code before it’s released (if
indeed it ever does get released), just send me a note off-list.
On 6/15/07, Rick O. [email protected] wrote:
map.resources :posts do |post|