Forum: Ruby on Rails catch-all routing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6fa76b3113f66ea5055ad3f10ab92819?d=identicon&s=25 Grayson Piercee (grayson)
on 2008-10-23 01:27
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
6fabb84e727dee98d1277df56458cbac?d=identicon&s=25 Andrew Bloom (Guest)
on 2008-10-23 02:00
(Received via mailing list)
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 Piercee <rails-mailing-l...@andreas-s.net>
6fa76b3113f66ea5055ad3f10ab92819?d=identicon&s=25 Grayson Piercee (grayson)
on 2008-10-23 04:23
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 Bloom 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 Piercee <rails-mailing-l...@andreas-s.net>
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2008-10-23 07:45
(Received via mailing list)
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"]}
This topic is locked and can not be replied to.