views:

19

answers:

1

Taking the 2 examples below - how do they work?

map.resources :api_developers, :path_prefix => '-'

map.connect '-/:controller/:action/:id', :requirements => { :controller => /metrics|labs/ }

+1  A: 

The :path_prefix option lets you add additional parameters that will be prefixed to the recognized paths. For example, suppose each photo in your application belongs to a particular photographer. In that case, you might declare this route:

map.resources :photos, :path_prefix => '/photographers/:photographer_id'

Routes recognized by this entry would include:

/photographers/1/photos/2
/photographers/1/photos

So yours samples

first one

/-/api_developers/
/-/api_developers/1
/-/api_developers/1/edit

etc

second one

/-/metrics/:action/:id
/-/labs/:action/:id

since there is no requirements on :action and :id they can be any string like

/-/metrics/first_string/second_string
Bohdan Pohorilets