I''m just now trying to figure out how rails routing works and to be honest, I find it really confusing. Anyway, I just want to create two "named" routes to save me some typing. The routes are: map.home '''', :controller => ''main'', :action => ''welcome'' map.login '''', :controller => ''user'', :action => ''login'' What happens is that when I do "redirect_to login_url", the first route is invoked. If I comment that first one out, then the second one starts working. Aren''t they in different namespaces? Why are they conflicting? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your routes are identical in the location that is rendered. The way you have it now any request that goes to http://www.yourdomain.com/ will use the map.home route since it is first in the list. try changing to something like: map.home '''', :controller => ''main'', :action => ''welcome'' map.login ''/login'', :controller => ''user'', :action => ''login'' The first argument is the url that is generated and must be unique. The controller and action definitions tell rails where to go when that url comes in. If you have duplicates then the first item found in the routes file will be used. Read up on routes and howw they work here ( http://wiki.rubyonrails.org/rails/pages/Routes ) to get a better understanding. - Adam On 6/29/07, surge <gerases-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I''m just now trying to figure out how rails routing works and to be > honest, I find it really confusing. Anyway, I just want to create two > "named" routes to save me some typing. The routes are: > > map.home '''', :controller => ''main'', :action => ''welcome'' > map.login '''', :controller => ''user'', :action => ''login'' > > What happens is that when I do "redirect_to login_url", the first > route is invoked. If I comment that first one out, then the second one > starts working. Aren''t they in different namespaces? Why are they > conflicting? > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Adam, thanks for the clarification. It''s definitely something I will need to learn in depth. Thanks a lot for the post. By the way, I was thinking about how I would go about creating a catchall route and I found this on the net: map.connect ''*path'', :controller => "some_controller", :action => "some_action" That star can''t be a regular expression star, so what is it and do you know where I could read about those details? Thanks once again, Sergei On Jun 30, 7:21 am, "Adam Parrott" <pingusk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your routes are identical in the location that is rendered. The way you have > it now any request that goes tohttp://www.yourdomain.com/will use the > map.home route since it is first in the list. > > try changing to something like: > map.home '''', :controller => ''main'', :action => ''welcome'' > map.login ''/login'', :controller => ''user'', :action => ''login'' > > The first argument is the url that is generated and must be unique. The > controller and action definitions tell rails where to go when that url comes > in. If you have duplicates then the first item found in the routes file will > be used. Read up on routes and howw they work here (http://wiki.rubyonrails.org/rails/pages/Routes) to get a better > understanding. > > - Adam > > On 6/29/07, surge <gera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m just now trying to figure out how rails routing works and to be > > honest, I find it really confusing. Anyway, I just want to create two > > "named" routes to save me some typing. The routes are: > > > map.home '''', :controller => ''main'', :action => ''welcome'' > > map.login '''', :controller => ''user'', :action => ''login'' > > > What happens is that when I do "redirect_to login_url", the first > > route is invoked. If I comment that first one out, then the second one > > starts working. Aren''t they in different namespaces? Why are they > > conflicting?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Funny you should ask about that. I stumbled across something similar and use the catchall for my 404''s. I didn''t really look into how it works at the time. # catch all... map.whoops ''*anything'', :controller => ''default'', :action => ''whoops'' I did find this though and it may clarify the use of the *. http://railscasts.com/episodes/46 -Adam On 6/30/07, surge <gerases-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Adam, thanks for the clarification. It''s definitely something I will > need to learn in depth. Thanks a lot for the post. By the way, I was > thinking about how I would go about creating a catchall route and I > found this on the net: > > map.connect ''*path'', :controller => "some_controller", :action => > "some_action" > > That star can''t be a regular expression star, so what is it and do you > know where I could read about those details? > > Thanks once again, > Sergei > > On Jun 30, 7:21 am, "Adam Parrott" <pingusk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Your routes are identical in the location that is rendered. The way you > have > > it now any request that goes tohttp://www.yourdomain.com/will use the > > map.home route since it is first in the list. > > > > try changing to something like: > > map.home '''', :controller => ''main'', :action => ''welcome'' > > map.login ''/login'', :controller => ''user'', :action => ''login'' > > > > The first argument is the url that is generated and must be unique. The > > controller and action definitions tell rails where to go when that url > comes > > in. If you have duplicates then the first item found in the routes file > will > > be used. Read up on routes and howw they work here ( > http://wiki.rubyonrails.org/rails/pages/Routes) to get a better > > understanding. > > > > - Adam > > > > On 6/29/07, surge <gera...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I''m just now trying to figure out how rails routing works and to be > > > honest, I find it really confusing. Anyway, I just want to create two > > > "named" routes to save me some typing. The routes are: > > > > > map.home '''', :controller => ''main'', :action => ''welcome'' > > > map.login '''', :controller => ''user'', :action => ''login'' > > > > > What happens is that when I do "redirect_to login_url", the first > > > route is invoked. If I comment that first one out, then the second one > > > starts working. Aren''t they in different namespaces? Why are they > > > conflicting? > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> http://railscasts.com/episodes/46It''s funny that this is where I found it too! Thanks Adam, I''ll look into it. Sergei --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---