config/routes.rb のURL書き換え機能 (Ruby on Rails)
>Rubyで書かれたRails用の mod_rewrite のようなURL書き換え機能です。定義ファイルは config/routes.rb です。
config/routes.rb の例:
ActionController::Routing::Routes.draw do |map|
map.connect '', :controller => "berryz", :action=> "index" # DirectoryIndex の例
map.connect ':controller/:action/:id' # Rails のデフォルトの書き換え例
end
上記設定の接続例:
1. http://localhost:3000/ にアクセス (パスは"")
2. route の1つめの定義の ^$ にマッチ
3. route の1つめの指示で "berryz"コントローラの"index"アクションを呼び出す
4. BerryzController#index を実行
5. そこで render された内容をページとして表示