Hi, From the rail recipe book, I found that it is possible to set up route rule so that the url can parsed and map differently. However, what I am trying to accomplish is that if /abc is typed and the controller abc does not exists, it will try to look into /app (i.e. app/abc). Is this possible? -- 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 -~----------~----~----~----~------~----~------~--~---
map.connect ":name", :controller => "app" where name is a GET parameter feed into the url on a link_to (or you can type your domain_name/<whatever_name> to access the page directly). On Mar 30, 1:35 pm, Wai Tsang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > From the rail recipe book, I found that it is possible to set up route > rule so that the url can parsed and map differently. However, what I am > trying to accomplish is that if /abc is typed and the controller abc > does not exists, it will try to look into /app (i.e. app/abc). Is this > possible? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
wilson wrote:> map.connect ":name", :controller => "app" > where name is a GET parameter feed into the url on a link_to (or you > can type your domain_name/<whatever_name> to access the page > directly). > > On Mar 30, 1:35 pm, Wai Tsang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks for the quick reply, but that route will only get to the app controller with params[:name] = ''abc''. I would like to go to the abc method instead of the index method, is it possible? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Wai, I use this exact route in my app for user homepages: map.connect '':id'', :controller => ''user'', :action => ''user_home'' this will make http://foo.com/joe map to that controller and action and pass the username joe to it There might be a better way even as I believe I''m perverting the use of :id in this case -Michael http://javathehutt.blogspot.com On Mar 30, 2007, at 1:35 PM, Wai Tsang wrote:> > Hi, > > From the rail recipe book, I found that it is possible to set up route > rule so that the url can parsed and map differently. However, what > I am > trying to accomplish is that if /abc is typed and the controller abc > does not exists, it will try to look into /app (i.e. app/abc). Is > this > possible? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Ff I''m reading it correctly, you want to get to the action ''abc'' with a controller of ''app''? map.connect "abc", :controller => "app", :action => "abc" This only requires the controller and the action when you create a link_to. As for the url, "domain_name/abc" should work. On Mar 30, 1:45 pm, Wai Tsang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> wilson wrote: > > map.connect ":name", :controller => "app" > > where name is a GET parameter feed into the url on a link_to (or you > > can type your domain_name/<whatever_name> to access the page > > directly). > > > On Mar 30, 1:35 pm, Wai Tsang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Thanks for the quick reply, but that route will only get to the app > controller with params[:name] = ''abc''. I would like to go to the abc > method instead of the index method, is it possible? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
On Mar 30, 3:35 pm, Wai Tsang <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > From the rail recipe book, I found that it is possible to set up route > rule so that the url can parsed and map differently. However, what I am > trying to accomplish is that if /abc is typed and the controller abc > does not exists, it will try to look into /app (i.e. app/abc). Is this > possible?Actually it''s pretty easy. In your routes.rb, try this: map.connect ''/:action'', :controller => ''app'' However, the order of your route rules in routes.rb is very important! Higher routes take priority. So if you still have the default catch-all route that Rails generates for you in your routes.rb (the :controller/:action:/:id route) make sure your route is *above* it. Also, you might not need that / that I''ve written. It could be that map.connect '':action'', :controller => ''app'' is correct. Whenever I have problems with routes, I comment out all the other routes, try the url in the browser again, and then look at the development log for an error message - it will tell you what it *thought* it was supposed to do with the url, which is usually enought insight to solve the problem. Jeff softiesonrails.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 -~----------~----~----~----~------~----~------~--~---