Rails3 Route 用法集锦
默认路由: Ruby代码 # Rails3: match '/:controller(/:action(/:id))' # Rails2: map.connect ':controller/:action/:id' 正则路由: Ruby代码 # Rails3: match 'products/:id' , :to => 'catalog#view' # Rails2: map.connect 'products/:id' , :controller => 'catalog' , :action => 'view' 命名路由: Ruby代码 # Rails3: match 'logout' , :to => 'sessions#destroy' , :as => 'logout' # Rails2: map.logout 'logout' , :controller => 'sessions' , :action => '' 根路由: Ruby代码 # Rails3: root => 'welcome#show' # Rails2: map.root :controller => 'welcome' , :action => 'show' 路由简写技巧: :to 键的省略: Ruby代码 match 'account' => 'account#index' # 相当于: match