Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1371 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Adds button_to helper for parity with link_to, making it easy to create safe action-triggering buttons

Reported by: tom@moertel.com Assigned to: David
Priority: high Milestone:
Component: ActionPack Version: 0.12.1
Severity: normal Keywords: get post idempotent button safe unsafe
Cc:

Description

This patch adds a button_to URL helper. Button_to has the same calling semantics as link_to and makes it as easy to create POST-powered buttons as it is to create links. It is designed to be a drop-in replacement for link_to for those situations where using a link would be unsafe, e.g., to trigger the deletion of a record. (See Section 9.1.1, "Safe Methods" of RFC 2616 - HTTP/1.1 for the full details.)

This patch is important because it provides a virtually zero-cost way for developers of Rails applications to "do the right thing" and avoid unsafe linking practices (which, as we have seen, can have disastrous, data-losing consequences). It is not a perfect solution, but it is effective for almost all real-world cases where unsafe links occur in Rails applications.

For more explanation, please see Taking the unsafe GETs out of Rails.

Attachments

button_to.diff (6.2 kB) - added by tom@moertel.com on 05/29/05 00:30:43.
This patch adds the button_to URL helper method
button_to.2.diff (6.2 kB) - added by tom@moertel.com on 06/01/05 14:18:18.
This patch (revised) adds the button_to URL helper method

Change History

05/29/05 00:30:43 changed by tom@moertel.com

  • attachment button_to.diff added.

This patch adds the button_to URL helper method

06/01/05 14:18:18 changed by tom@moertel.com

  • attachment button_to.2.diff added.

This patch (revised) adds the button_to URL helper method

06/16/05 06:17:53 changed by david

  • status changed from new to closed.
  • resolution set to fixed.