2008年9月21日 星期日

The rails way ch3 routing


trigger a branching on respond_to by setting the HTTP-Accept header in the request
p70.

wget http://localhost:3000/items/show/3 -0 - -header="Accept:text/xml"



The Empty Route

map.root :controller => "homepage"



Using Regular Expression in Routes

map.connect ':controller/show/:id',
:action = "show", :requirements => {:id => /\d+/}



Route Globbing & key-value pairs

map.connect 'items/*specs', :controller => "items", :action => 'specify'

def specify
@items = Item.find(:all, :conditions => Hash[params[:specs]])
...
end


沒有留言: