Different REST routes to index w parameter

right now I am using the following routes to 3 actions : index (get
all messages) , received (get all received messages) and sent (get all
sent message…

map.resource :user do |user|
user.resources :messages, :collection => {:received => :get, :sent
=> :get}
which gives me the following urls to be used…

  • /user/messages;sent/
  • /user/messages;received/
  • /user/messages/

I am quite sure I can have only one action (index) with a parameter to
differentiate the requested resource

  • /user/messages/:type
    0 all
    1 sent
    2 received

I tried the follwing, but I lost the nesting resource (user)
map.messages ‘messages’ :controller => ‘messages’, :action =>

how can I write this kind of routing ?
thanks for your help