alias resource route

Hi. I have a resource named item. So in my routes.rb I have:

map.resources :item

and I can go to http://localhost:3000/items and see all my items

If I go to /items/1 and see details for item 1 since I am routed to the show action, etc.

This is great but I would also like users to be able to go to a different route as well as item - say myitems. So if a user types in /items or /myitems I want them to go to the same place - controller => items, :action => index

I can define an individual route for each route like:

map.connect 'myitems', :controller => 'items', :action => 'index' map.connect 'myitems/:id', :controller => 'items', :action => ...

but this is not nearly as nice as :resources where I get all those routes created automatically. Can anyone help with this?

If you want to get all the pre-established routes for your "myitems" controller then what you want to do is:

map.resources :myitems, :controller => "items"

And then what’s stopping that user from typing in an ID and showing an item that should not be in “myitems”. More security please.

Thiago Jackiw wrote:

If you want to get all the pre-established routes for your "myitems" controller then what you want to do is:

map.resources :myitems, :controller => "items"

-- Thiago Jackiw http://www.railsfreaks.com

On May 13, 12:11 pm, Explore Apps <rails-mailing-l...@andreas-s.net>

Thiago,

Thanks very much. This was exactly what I was looking for. It works perfectly!