アプリケーションを参照するURLを生成
url_for(オプション)
オプション | 説明 | デフォルト |
---|---|---|
:anchor | アンカー(URLの#以降)を指定 | |
:only_path | trueなら、URL全体ではなくパス部分を返す | false |
:trailing_slash | If true, adds a trailing slash, as in “/archive/2005/“. Note that this is currently not recommended since it breaks caching. | |
:host | URLのホストを指定 | |
:protocol | URLのプロトコルを指定 | |
:user | インライン認証を指定 | |
:password | インライン認証を指定 |
<%= url_for :controller => 'pages', :action => 'show' %>
# => '/pages/show'
<%= url_for :controller => 'pages', :action => 'show' %>
# => '/pages/show'
<%= url_for :controller => 'pages', :action => 'show', :only_path => false %>
# => 'http://localhost/pages/show'