Rails 2.0 RESTful Routes action/id dichotomy

I don't have edge rails installed, otherwise I would just test it
out. But in Rails 2.0 they are doing away with the semi-colon for
several reasons. I think this is great, but it brings an interesting
issue to the forefront that's actually bothered me in 1.2 as well...

How will Rails differentiate between an action on the collection and
the id? For instance, if you have:

map.resources :listings, :collection => {:search => :get}

listings/1
listings/search (in 1.2 t it would be listings;search)

Interestingly this problem existed before if you tried to mix default
routing with RESTful routes which you might want to do for aesthetic
or hackish reasons.

It is my understanding that most are recommending removing the default
routes when using RESTful Rails.

  # Resources routes
  map.resources :listings, :collection => {:search => :get}

  # Install the default route as the lowest priority.
  # map.connect ':controller/:action/:id.:format'
  # map.connect ':controller/:action/:id'

But other than that, the same precedence is used in following routes
as before.

Hey,

sorry if I've misinterpreted what you're saying - but you're
speculating about a problem that (again, if I understand you
correctly) does not exist.

The resources code (see resources.rb) adds collection routes before
member routes - which means collection routes will take precedence
during recognition.

HTH,
Trevor

Interestingly this problem existed before if you tried to mix default
routing with RESTful routes which you might want to do for aesthetic
or hackish reasons.

Put your restful routes above your default routes. I actually remove
my default ones altogether.

Right, that's the scenario I was thinking of. But I guess as long as
you make sure your URL slugs never conflict with an action you'll be
okay.

Jean-Etienne Durand wrote:
> But still, if you use smart urls, you can never know if in
> /people/whatever whatever is an action, or an ID...

Custom actions are defined explicitly, so you do know. Anything that's
defined explicitly is not an id. Usually, ids are in another class
entirely anyway. Like they're purely integers or they follow a stand
form of perhaps 1-my-title. So there's not even any logical overlap.