I just spend a while trying to figure this out - the documentation in  
routing.rb is out of date.
A route like:

map.connect ':controller/:action/:id', :action => 'show', :defaults =>  
{ :page => 'Dashboard' }

will blow up with an error. (`assign_route_options': page: No matching  
segment exists; cannot assign default (ArgumentError)).

Turns out, after digging around, that the correct way to do this is now:

map.connect ':controller/:action/:id', :action => 'show', :page =>  
'Dashboard'

--
On a related note, it isn't documented *anywhere* that you can pass  
extra parameters like this to
resource routes, if you use requirements:

map.resources :things, :requirements => { :extra_param => 'whatever' }

Which will call all the REST actions with :extra_param => 'whatever'.  
It's really handy for cases where you might want
to disambiguate multiple paths to the same resource, ie:

map.resource :library do |p|
   p.resources :comments, :requirements => {:type => 'library'}
end
map.resource :archive do |p|
   p.resources :comments, :requirements => {:type => 'archive'}
end

Both /library/comments and /archive/comments will map to  
CommentsController, so the :type will tell the two apart.
(Note that plural resources get a (resource)_id value, but singular  
resources do not.)
--

The syntax above for named routes is a little odd; it doesn't seem  
that many people would guess that :requirements was
what they're looking for. Thoughts?

--Matt Jones
[EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to