Railsドキュメント

指定したURLが現在表示されているかチェック

適応バージョン

説明

指定したURLが、現在表示されているかチェック

使い方

current_page?(オプション [, check_parameters: false])

表示されていない場合

current_page?(action: 'process')
# false

アクションを指定

current_page?(action: 'checkout')
# true

コントローラとアクションを指定

current_page?(controller: 'library', action: 'checkout')
# false

パラメータを指定

current_page?(controller: 'shop', action: 'checkout', order: 'asc')
# false

URLを指定

current_page?('http://www.example.com/shop/checkout')
# true

パラメータをチェック

current_page?('http://www.example.com/shop/checkout', check_parameters: true)
# false

クエリを指定

current_page?('http://www.example.com/shop/checkout?order=desc&page=1')
# true

ソースコード