Catch-all routing


#1

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/gm/solstice

I know you can do it like this

http://localhost:3000/manufacturers/ford/thunderbird
http://localhost:3000/manufacturers/gm/solstice

but is it possible to skip the controller name?

TIA.

GP


#2

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


#3

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


#4

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”]}