RESTful URL quesiton

Tyler MacDonald
Tue, 03 Apr 2007 23:00:24 -0000

Hey everybody,

	I''ve started trying to be a bit fancier with my URLs, and
it''s
biting me back. :-(

	I am working on a set of controllers to allow people to directly
manipulate database records... Since they all perform a similar task,
I''ve
nested them all into the "records" namespace (Records::Name ->
records/name), etc.

	The main problem: URL recognition.

	I have a top-level "records" controller as well. But it seems that
rails wants to divert -everything- to do with records to that controller,
instead of picking up on sub-controllers (records/name, etc). eg; if I look
up "records/name" I get "no action responded to name"... If
I try to fill
out all of the fields (records/name/index/5, say) -- i get "Recognition
failed for..."

 	If I write a rule like this above the ":controller/:action/:id"
rule, everythng works:

  map.connect ''records/name/:action/:id'',
    :controller => ''records/name''

	... but of course I don''t want to have to write a rule like that for
every single sub-controller.

	Is there any way to convince routing to look for the longest
possible controller name first, so that it always finds "records/name"
before just plain ol'' "records"?

	Thanks,
		Tyler