current_page?(options)
Instance Public methods
True if the current request URI was generated
by the given options
.
Examples
Let's say we're in the
http://www.example.com/shop/checkout?order=desc
action.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | current_page?(action: 'process' ) # => false current_page?(controller: 'shop' , action: 'checkout' ) # => true current_page?(controller: 'shop' , action: 'checkout' , order: 'asc' ) # => false current_page?(action: 'checkout' ) # => true current_page?(controller: 'library' , action: 'checkout' ) # => false # => true current_page?( '/shop/checkout' ) # => true |
Let's say we're in the
http://www.example.com/shop/checkout?order=desc&page=1
action.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | current_page?(action: 'process' ) # => false current_page?(controller: 'shop' , action: 'checkout' ) # => true current_page?(controller: 'shop' , action: 'checkout' , order: 'desc' , page: '1' ) # => true current_page?(controller: 'shop' , action: 'checkout' , order: 'desc' , page: '2' ) # => false current_page?(controller: 'shop' , action: 'checkout' , order: 'desc' ) # => false current_page?(action: 'checkout' ) # => true current_page?(controller: 'library' , action: 'checkout' ) # => false |
Let's say we're in the http://www.example.com/products
action with method POST in case of invalid product.
1 2 | current_page?(controller: 'product' , action: 'index' ) # => false |
Please login to continue.