# Catch-all routing

**URL:** <https://www.ruby-forum.com/t/catch-all-routing/151566>\
**Category:** Rails\
**Created:** [October 23, 2008, 1:27am UTC](https://www.ruby-forum.com/t/catch-all-routing/151566 "2008-10-23T01:27:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [October 23, 2008, 1:27am UTC](https://www.ruby-forum.com/t/catch-all-routing/151566/1 "2008-10-23T01:27:53Z")

</div>

I know this isn’t all that Rails friendly but is it possible to do  
catch-all routing so that some value can be passed in as if it were a  
controller for example

[http://localhost:3000/ford/thunderbird](http://localhost:3000/ford/thunderbird)  
[http://localhost:3000/gm/solstice](http://localhost:3000/gm/solstice)

I know you can do it like this

[http://localhost:3000/manufacturers/ford/thunderbird](http://localhost:3000/manufacturers/ford/thunderbird)  
[http://localhost:3000/manufacturers/gm/solstice](http://localhost:3000/manufacturers/gm/solstice)

but is it possible to skip the controller name?

TIA.

GP

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [October 23, 2008, 2:00am UTC](https://www.ruby-forum.com/t/catch-all-routing/151566/2 "2008-10-23T02:00:35Z")

</div>

map.connect “:manufacturer\_name/:model\_name”, :controller =\>  
“manufactuers”, :action =\> “show”

in your controller params[:manufacturer\_name] and params[:model\_name]  
should be available

On Oct 22, 6:27 pm, Grayson P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [October 23, 2008, 4:23am UTC](https://www.ruby-forum.com/t/catch-all-routing/151566/3 "2008-10-23T04:23:43Z")

</div>

Andrew,

Sorry I should have mentioned that I won’t know the manufacturer names  
ahead of time (in other words, I want to make it data driven). That’s  
what I meant by catch-all.

Andrew B. wrote:

> map.connect “:manufacturer\_name/:model\_name”, :controller =\>  
> “manufactuers”, :action =\> “show”
> 
> in your controller params[:manufacturer\_name] and params[:model\_name]  
> should be available
> 
> On Oct 22, 6:27ï¿½pm, Grayson P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![grayson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c77e96/32.png) [@grayson](https://www.ruby-forum.com/u/grayson)\
**Post date:** [October 23, 2008, 7:45am UTC](https://www.ruby-forum.com/t/catch-all-routing/151566/4 "2008-10-23T07:45:40Z")

</div>

map.static ‘:permalink’, :controller =\> ‘pages’, :action =\> ‘show’

or

map.connect “\*path”, :controller =\> “four\_oh\_fours”

First on is not great and you need to handle 404s in that  
controller… the second is well an example from a 404 controller BUT  
it shows the \*path example… if you do /bla1/bla2/bla3 that’s what  
you get in the params…

Parameters: {“action”=\>“index”, “controller”=\>“four\_oh\_fours”,  
“path”=\>[“bla1”, “bla2”, “bla3”]}
