Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make button_to arguments explicit and refactor a bit

Prefer Hash#[]= over Hash#merge when setting a value.
  • Loading branch information...
commit 6471e09217926048be9ff8d05f21863773838b7d 1 parent a76b0cf
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 6 additions and 10 deletions.
  1. +6 −10 actionpack/lib/action_view/helpers/url_helper.rb
View
16 actionpack/lib/action_view/helpers/url_helper.rb
@@ -341,15 +341,10 @@ def link_to(*args, &block)
# # </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 @@ def button_to(*args, &block)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.