diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index b2c6311c5a..8ba3df379b 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -78,7 +78,7 @@ module ActionView # given block is yielded, if one exists). This is useful for creating link bars where you don't want to link # to the page currently being viewed. def link_to_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference) - if url_for(options) == @request.request_uri + if current_page?(options) block_given? ? yield(name, options, html_options, *parameters_for_method_reference) : html_escape(name) @@ -120,6 +120,11 @@ module ActionView end end + # Returns true if the current page uri is generated by the options passed (in url_for format). + def current_page?(options) + url_for(options) == @request.request_uri + end + private def convert_confirm_option_to_javascript!(html_options) if html_options.include?(:confirm)