u16suzuの blog

日々学んだことのメモブログです。

routes.rb ファイルを読んでみる。

routes.rb ファイルを読んでみました。そのメモです。

優先度は順番による。一番最初に書かれたものが、一番優先度高い。

ルーティングに変数を使える。
str = "entries33"
match 'hoge' => str + "#index"

# => hoge        /hoge(.:format)           {:action=>"index", :controller=>"entries33"}

:as で、ルーティングに名前を付けられる。つまり、Urlヘルパー名を指定できる。

match 'hoge/:id' => 'entries#show', :as => :foo

# => foo        /hoge/:id(.:format)       {:controller=>"entries", :action=>"show"}

ネストできる。