# Routing every request to same action

**URL:** <https://www.ruby-forum.com/t/routing-every-request-to-same-action/164289>\
**Category:** Deployment\
**Created:** [March 30, 2009, 11:07pm UTC](https://www.ruby-forum.com/t/routing-every-request-to-same-action/164289 "2009-03-30T23:07:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![umair](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e495f1/32.png) [@umair](https://www.ruby-forum.com/u/umair)\
**Post date:** [March 30, 2009, 11:07pm UTC](https://www.ruby-forum.com/t/routing-every-request-to-same-action/164289/1 "2009-03-30T23:07:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![umair](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e495f1/32.png) [@umair](https://www.ruby-forum.com/u/umair)\
**Post date:** [May 6, 2009, 10:44pm UTC](https://www.ruby-forum.com/t/routing-every-request-to-same-action/164289/2 "2009-05-06T22:44:43Z")

</div>

Try this in your routes.rb

map.connect “\*anything”, :controller =\> “companies”, :action =\>  
“index”

I tried only a few examples and it seems to work. Though I think you  
will need to place this line before the two generic connect commands as  
below

map.connect “\*anything”, :controller =\> “companies”, :action =\>  
“index”  
map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

If you are going to route all your requests to companies/index then you  
probably don’t need the last two connect commands anyways and can get  
rid of them.

-S
