diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 8843a89362..afb1265ad9 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -476,21 +476,27 @@ module ActionView # 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. + # Let's say we're in the http://www.example.com/shop/checkout?order=desc&page=1 action. # # current_page?(action: 'process') # # => false # + # current_page?(action: 'checkout') + # # => true + # + # current_page?(controller: 'library', action: 'checkout') + # # => false + # # current_page?(controller: 'shop', action: 'checkout') # # => true # # current_page?(controller: 'shop', action: 'checkout', order: 'asc') # # => false # - # current_page?(action: 'checkout') + # current_page?(controller: 'shop', action: 'checkout', order: 'desc', page: '1') # # => true # - # current_page?(controller: 'library', action: 'checkout') + # current_page?(controller: 'shop', action: 'checkout', order: 'desc', page: '2') # # => false # # current_page?('http://www.example.com/shop/checkout') @@ -499,34 +505,16 @@ module ActionView # current_page?('/shop/checkout') # # => true # - # Let's say we're in the http://www.example.com/shop/checkout?order=desc&page=1 action. - # - # current_page?(action: 'process') - # # => false - # - # current_page?(controller: 'shop', action: 'checkout') + # current_page?('http://www.example.com/shop/checkout?order=desc&page=1') # # => 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. # # current_page?(controller: 'product', action: 'index') # # => false # + # We can also pass in the symbol arguments instead of strings. + # def current_page?(options) unless request raise "You cannot use helpers that need to determine the current " \