Hi, I have some problem, I want to route every request from URL to an action in my one controller. Like if I enter localhost:3000/rac .Here it will take the ''rac'' as a controller name and then route it to the ''index'' action of the ''rac'' controller. But what I want is that it should redirect towards :controller=>''companies'' :action=>''index'' , doesnt matter that ''rac'' controller exisits or not, It should just redirect to my desired controller/action. I tried this in my routes.rb map.connect ''parts/:number'',:controller=>''companies'' , :action=>''index'' But its not working. Please help me to overcome this problem, Thanks in advance, Regards, Umair -- 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 -~----------~----~----~----~------~----~------~--~---
Please let me know if any one know how to do 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 -~----------~----~----~----~------~----~------~--~---
On Mon, 2009-03-30 at 23:08 +0200, Umair Ejaz wrote:> Please let me know if any one know how to do thisI''m not sure I understand exactly what you want to do but if you really want _every_ request to get routed to the same action, you can use a before_filter. In application.rb: def route_all_to_somewhere redirect_to :controller => ''desired_controller'', :action => ''desired_action'' end and either at the beginning of application.rb or in each of your controller files: before_filter :route_all_to_somewhere HTH, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks dear this will work fine if I write before_filter :route_all_to_somewhere in start of my all controllers but if the controller doesnt exist, means he write locahost:3000/rac and there is not ''rac'' controller then how can I redirect this request towards my desired action...It willl simply give the routing error that "No route matches "/rac" with". What I want is that it should nt gimme this error even if i write the name of the controller in URL which doesnt exists, It should always redirect to my desiredt action -- 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 the requirement is to direct every incoming request for a particular action in a controller then can just have map.connect ''*path'', :controller=>"your_controller", :action=>"your_action" in the routes.rb file. This will redirect every request to ''your_action'' in ''your_controller''. Regards, Madhusudhan -- 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 -~----------~----~----~----~------~----~------~--~---
Thank you soooo mcuh!!!thats what i was looking for! thanks again -- 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 -~----------~----~----~----~------~----~------~--~---