Fix a button_to documentation example

Fixes an example in `button_to`'s documentation; the description states
`button_to` only takes a symbol for the `method` argument, but an
example just below uses a string.

Passing an all-lowercase string incidentally works, so the example is
technically functional despite being undefined behavior. But passing an
all-uppercase string fails, and this is a pretty common practice when
specifying HTTP methods (e.g. `DELETE`), so I think it's best this
example is put in line with the documentation and converted to use
symbols.

I fell for it myself and tried to pass an all-uppercase string after
seeing the example without reading the options descriptions.

Reproduction steps:

```sh
rails new buttonto
cd buttonto
rails c
> def protect_against_forgery?
>   false
> end
=> :protect_against_forgery?
>  button_to('Destroy', 'http://www.example.com', method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' })
=> "<form class=\"button_to\" method=\"post\" action=\"http://www.example.com\" data-remote=\"true\"><input type=\"hidden\" name=\"_method\" value=\"delete\" /><input data-confirm=\"Are you sure?\" data-disable-with=\"loading...\" type=\"submit\" value=\"Destroy\" /></form>"
>  button_to('Destroy', 'http://www.example.com', method: "DELETE", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' })
=> "<form class=\"button_to\" method=\"post\" action=\"http://www.example.com\" data-remote=\"true\"><input data-confirm=\"Are you sure?\" data-disable-with=\"loading...\" type=\"submit\" value=\"Destroy\" /></form>"
```
This commit is contained in:
glacials 2019-09-12 18:46:40 -07:00
parent b13c518ddf
commit c2cadd2f6d
No known key found for this signature in database
GPG Key ID: 163E10E9ACF51D0B

@ -290,7 +290,7 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
#
#
# <%= button_to('Destroy', 'http://www.example.com',
# method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
# method: :delete, remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
# # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>
# # <input name='_method' value='delete' type='hidden' />
# # <input value='Destroy' type='submit' data-disable-with='loading...' data-confirm='Are you sure?' />