aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 12:25:52 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 12:25:52 +0000
commit3e4064e9f2ce85697474aab03e27e69bf763e740 (patch)
tree11f573cdd5f53915cd05843fef9ad843236f5695 /actionpack/lib
parent5199aea4aa5d07cf978270f22d03abefbee245c2 (diff)
downloadrails-3e4064e9f2ce85697474aab03e27e69bf763e740.tar.gz
rails-3e4064e9f2ce85697474aab03e27e69bf763e740.tar.bz2
rails-3e4064e9f2ce85697474aab03e27e69bf763e740.zip
Simplified link_to_unless_current to work with the new Routing
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@644 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb27
1 files changed, 3 insertions, 24 deletions
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 0661c961b6..b2c6311c5a 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -74,18 +74,16 @@ module ActionView
end
# Creates a link tag of the given +name+ using an URL created by the set of +options+, unless the current
- # controller, action, and id are the same as the link's, in which case only the name is returned (or the
+ # request uri is the same as the link's, in which case only the name is returned (or the
# 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)
- assume_current_url_options!(options)
-
- if destination_equal_to_current(options)
+ if url_for(options) == @request.request_uri
block_given? ?
yield(name, options, html_options, *parameters_for_method_reference) :
html_escape(name)
else
- link_to name, options, html_options, *parameters_for_method_reference
+ link_to(name, options, html_options, *parameters_for_method_reference)
end
end
@@ -123,25 +121,6 @@ module ActionView
end
private
- def destination_equal_to_current(options)
- params_without_location = @params.reject { |key, value| %w( controller action id ).include?(key) }
-
- options[:action].to_s == @params['action'].to_s &&
- options[:id].to_s == @params['id'].to_s &&
- options[:controller].to_s == @params['controller'].to_s &&
- (options.has_key?(:params) ? params_without_location == options[:params] : true)
- end
-
- def assume_current_url_options!(options)
- if options[:controller].nil?
- options[:controller] = @params['controller']
- if options[:action].nil?
- options[:action] = @params['action']
- if options[:id].nil? then options[:id] ||= @params['id'] end
- end
- end
- end
-
def convert_confirm_option_to_javascript!(html_options)
if html_options.include?(:confirm)
html_options["onclick"] = "return confirm('#{html_options[:confirm]}');"