Skip to content

Commit 3b1fae4

Browse files
authored
Merge pull request rails#41886 from jacobherrington/add-example-for-params-button-to-doc
Add example of params to button_to docs [ci skip]
2 parents 8096666 + 4bfc35a commit 3b1fae4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

actionview/lib/action_view/helpers/url_helper.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,20 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
257257
# <%= button_to "New", action: "new" %>
258258
# # => "<form method="post" action="/controller/new" class="button_to">
259259
# # <button type="submit">New</button>
260+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
260261
# # </form>"
261262
#
262263
# <%= button_to "New", new_article_path %>
263264
# # => "<form method="post" action="/articles/new" class="button_to">
264265
# # <button type="submit">New</button>
266+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
267+
# # </form>"
268+
#
269+
# <%= button_to "New", new_article_path, params: { time: Time.now } %>
270+
# # => "<form method="post" action="/articles/new" class="button_to">
271+
# # <button type="submit">New</button>
272+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
273+
# # <input type="hidden" name="time" value="2021-04-08 14:06:09 -0500">
265274
# # </form>"
266275
#
267276
# <%= button_to [:make_happy, @user] do %>
@@ -271,21 +280,21 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
271280
# # <button type="submit">
272281
# # Make happy <strong><%= @user.name %></strong>
273282
# # </button>
283+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
274284
# # </form>"
275285
#
276286
# <%= button_to "New", { action: "new" }, form_class: "new-thing" %>
277287
# # => "<form method="post" action="/controller/new" class="new-thing">
278288
# # <button type="submit">New</button>
289+
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
279290
# # </form>"
280291
#
281-
#
282292
# <%= button_to "Create", { action: "create" }, remote: true, form: { "data-type" => "json" } %>
283293
# # => "<form method="post" action="/images/create" class="button_to" data-remote="true" data-type="json">
284294
# # <button type="submit">Create</button>
285295
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
286296
# # </form>"
287297
#
288-
#
289298
# <%= button_to "Delete Image", { action: "delete", id: @image.id },
290299
# method: :delete, data: { confirm: "Are you sure?" } %>
291300
# # => "<form method="post" action="/images/delete/1" class="button_to">
@@ -294,7 +303,6 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
294303
# # <input name="authenticity_token" type="hidden" value="10f2163b45388899ad4d5ae948988266befcb6c3d1b2451cf657a0c293d605a6"/>
295304
# # </form>"
296305
#
297-
#
298306
# <%= button_to('Destroy', 'http://www.example.com',
299307
# method: :delete, remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' }) %>
300308
# # => "<form class='button_to' method='post' action='http://www.example.com' data-remote='true'>

0 commit comments

Comments
 (0)