How To Make Safe Buttons

The administrator's interface on GiveALink has a button for clearing all similarities. This button has a quick javascript "Are you sure?" confirmation so that it's a little harder to inadvertently truncate ALL the similarities in the database. If anyone wants this feature on any other part of the site, the code is easy in Rails:

     'clear_similarities'}, :confirm => "Are you absolutely sure?" %>

Obviously, you substitute whatever method you need for the ":action =>" part, and you can change both the message on the button and the message in the drop down alert to suit your taste.

Note that "button_to" is declared the best practice for resisting bot attempts to operate forms. See http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001598.