From 6471e09217926048be9ff8d05f21863773838b7d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 30 May 2012 22:44:30 -0300 Subject: Make button_to arguments explicit and refactor a bit Prefer Hash#[]= over Hash#merge when setting a value. --- actionpack/lib/action_view/helpers/url_helper.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'actionpack/lib/action_view/helpers/url_helper.rb') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index a4b10bc68a..a0fa7d27e9 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -341,15 +341,10 @@ module ActionView # # # # " # # - def button_to(*args, &block) - if block_given? - options = args[0] || {} - html_options = args[1] || {} - else - name = args[0] - options = args[1] || {} - html_options = args[2] || {} - end + def button_to(name = nil, options = nil, html_options = nil, &block) + html_options, options = options, name if block_given? + options ||= {} + html_options ||= {} html_options = html_options.stringify_keys convert_boolean_attributes!(html_options, %w(disabled)) @@ -374,7 +369,8 @@ module ActionView button = if block_given? content_tag('button', html_options, &block) else - tag('input', html_options.merge('value' => name || url)) + html_options['value'] = name || url + tag('input', html_options) end inner_tags = method_tag.safe_concat(button).safe_concat(request_token_tag) -- cgit v1.2.3