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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi. I have a resource named item. So in my routes.rb I have: > > map.resources :item > > and I can go tohttp://localhost:3000/itemsand 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? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Wed, May 14, 2008 at 6:49 AM, Thiago Jackiw <tjackiw-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > Hi. I have a resource named item. So in my routes.rb I have: > > > > map.resources :item > > > > and I can go tohttp://localhost:3000/itemsand 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? > > -- > > Posted viahttp://www.ruby-forum.com/. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thiago, Thanks very much. This was exactly what I was looking for. It works perfectly! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---