views:

510

answers:

1

For the caching purpose I can't have url like /users/2/index?month=2009-02 . The problem with this approach is that if I do page caching then same page is returned even for /users/2/index?month=2009-03 .

To solve the caching issue I would like to have url like /users/2/events/2009-02.html . I have defined users to be a restful resource.

map.resources :users

Does anyone know how to get url like /users/2/events/2009-02.html which will map to

controller = users action = events id = 2 or user_id = 2 month = 2009-02

+9  A: 

In your application's routes file, you can set up a named route like this:

map.user_events '/users/:user_id/events/:month.html', :controller => :users, :action => :events, :requirements => {:month => /[0-9]{4}-[0-9]{2}/}

There's more information on routing here: http://guides.rubyonrails.org/routing.html

georgebrock