mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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:
parent
b13c518ddf
commit
c2cadd2f6d
1 changed files with 1 additions and 1 deletions
|
@ -290,7 +290,7 @@ module ActionView
|
|||
#
|
||||
#
|
||||
# <%= 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?' />
|
||||
|
|
Loading…
Reference in a new issue