aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-05-30 22:44:30 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-05-31 09:38:24 -0300
commit6471e09217926048be9ff8d05f21863773838b7d (patch)
tree50806c1361cca3a0f4fddffb9cf320842398dafc
parenta76b0cf8e542f8b747f57abc88a642a0d4ec833c (diff)
downloadrails-6471e09217926048be9ff8d05f21863773838b7d.tar.gz
rails-6471e09217926048be9ff8d05f21863773838b7d.tar.bz2
rails-6471e09217926048be9ff8d05f21863773838b7d.zip
Make button_to arguments explicit and refactor a bit
Prefer Hash#[]= over Hash#merge when setting a value.
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb16
1 files changed, 6 insertions, 10 deletions
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
# # </div>
# # </form>"
# #
- 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)