diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 63b65574d36a7..3b62fb5222e08 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -173,6 +173,28 @@ def _filtered_referrer # :nodoc: # link_to "External link", "http://www.rubyonrails.org/", target: "_blank", rel: "nofollow" # # => External link # + # ==== Turbo + # + # Rails 7 ships with Turbo enabled by default. Turbo provides the following +:data+ options: + # + # * turbo_method: symbol of HTTP verb - Performs a Turbo link visit + # with the given HTTP verb. Forms are recommended when performing non-+GET+ requests. + # Only use data-turbo-method where a form is not possible. + # + # * turbo_confirm: "question?" - Adds a confirmation dialog to the link with the + # given value. + # + # {Consult the Turbo Handbook for more information on the options + # above.}[https://turbo.hotwired.dev/handbook/drive#performing-visits-with-a-different-method] + # + # ===== \Examples + # + # link_to "Delete profile", @profile, data: { turbo_method: :delete } + # # => Delete profile + # + # link_to "Visit Other Site", "https://rubyonrails.org/", data: { turbo_confirm: "Are you sure?" } + # # => Visit Other Site + # # ==== Deprecated: \Rails UJS Attributes # # Prior to \Rails 7, \Rails shipped with a JavaScript library called @rails/ujs on by default. Following \Rails 7, @@ -224,9 +246,6 @@ def link_to(name = nil, options = nil, html_options = nil, &block) # Generates a form containing a single button that submits to the URL created # by the set of +options+. This is the safest method to ensure links that # cause changes to your data are not triggered by search bots or accelerators. - # If the HTML button does not work with your layout, you can also consider - # using the +link_to+ method with the :method modifier as described in - # the +link_to+ documentation. # # You can control the form and button behavior with +html_options+. Most # values in +html_options+ are passed through to the button element. For @@ -240,6 +259,10 @@ def link_to(name = nil, options = nil, html_options = nil, &block) # The form submits a POST request by default. You can specify a different # HTTP verb via the +:method+ option within +html_options+. # + # If the HTML button generated from +button_to+ does not work with your layout, you can + # consider using the +link_to+ method with the +data-turbo-method+ + # attribute as described in the +link_to+ documentation. + # # ==== Options # The +options+ hash accepts the same options as +url_for+. To generate a #
element without an [action] attribute, pass