Hi all, I want the url something like this: http://localhost:3000/profile/anyusername This will access the controller: profile and the action: view and the value "anyusername" is the :username parameter. So I wrote in my route file something like this map.connect ''profile/:username'', :controller => ''profile'', :action=>''view'' But what I want more is that except for the value "index","edit", and "update". When the user type the url: http://localhost:3000/profile/index, it will access controller: profile and action: index. For "edit" and "update" are in the same process. So my finally route is: map.connect ''profile/index'', :controller => ''profile'', :action=>''index'' map.connect ''profile/edit'', :controller => ''profile'', :action=>''edit'' map.connect ''profile/update'', :controller => ''profile'', :action=>''update'' map.connect ''profile/:username'', :controller => ''profile'', :action=>''view'' And they are working fine. But I think it''s too long. Are there any ways that is shorter than the above. Thanks in advance, Mako --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Mar 10, 2009 at 9:47 AM, Mako <makarakao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > I want the url something like this: > > http://localhost:3000/profile/anyusername > > This will access the controller: profile and the action: view and the > value "anyusername" is the :username parameter. > So I wrote in my route file something like this > > map.connect ''profile/:username'', :controller => > ''profile'', :action=>''view'' > > But what I want more is that except for the value "index","edit", and > "update". When the user type the url: > > http://localhost:3000/profile/index, it will access controller: > profile and action: index. For "edit" and "update" are in the same > process. > > So my finally route is: > > map.connect ''profile/index'', :controller => > ''profile'', :action=>''index'' > map.connect ''profile/edit'', :controller => ''profile'', :action=>''edit'' > map.connect ''profile/update'', :controller => > ''profile'', :action=>''update'' > map.connect ''profile/:username'', :controller => > ''profile'', :action=>''view'' > > And they are working fine. But I think it''s too long. > Are there any ways that is shorter than the above. > > Thanks in advance, > > Mako > > > >What about: map.connect ''profile/:username'', :controller => ''profile'', :action => ''view'' map.connect ''profile/:action'', :controller => ''profile'' Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Andrew Timberlake wrote:> On Tue, Mar 10, 2009 at 9:47 AM, Mako <makarakao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi all, >> >> I want the url something like this: >> >> http://localhost:3000/profile/anyusername >> >> This will access the controller: profile and the action: view and the >> value "anyusername" is the :username parameter. >> So I wrote in my route file something like this >> >> map.connect ''profile/:username'', :controller => >> ''profile'', :action=>''view'' >> >> But what I want more is that except for the value "index","edit", and >> "update". When the user type the url: >> >> http://localhost:3000/profile/index, it will access controller: >> profile and action: index. For "edit" and "update" are in the same >> process. >> >> So my finally route is: >> >> map.connect ''profile/index'', :controller => >> ''profile'', :action=>''index'' >> map.connect ''profile/edit'', :controller => ''profile'', :action=>''edit'' >> map.connect ''profile/update'', :controller => >> ''profile'', :action=>''update'' >> map.connect ''profile/:username'', :controller => >> ''profile'', :action=>''view'' >> >> And they are working fine. But I think it''s too long. >> Are there any ways that is shorter than the above. >> >> Thanks in advance, >> >> Mako >> > > What about: > map.connect ''profile/:username'', :controller => ''profile'', :action => ''view'' > map.connect ''profile/:action'', :controller => ''profile'' > > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twainmap.connect ''/profile/:action'', :controller => ''profile'', :requirements => {:action => /(edit|update|new|index)/ } map.connect ''/profile/:username'', :controller => ''profile'', :action => ''view'' tom -- ==============================================================================Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz ============================================================================== --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---