How to add confirm message with link_to Ruby on rails

后端 未结 10 1694
[愿得一人]
[愿得一人] 2020-12-29 17:45

I wanted to add confirmation message on link_to function with Ruby.

= link_to \'Reset message\', :action=>\'reset\' ,:confirm=>\'Are you sure?\'
         


        
10条回答
  •  粉色の甜心
    2020-12-29 18:11

    <%= link_to "Delete this article", article_path(article), method: :delete,
                        data: { confirm: "Are you sure you want to delete the 
                        article?"}, class: "btn btn-xs btn-danger" %>
    

    A button link where article_path is the prefix and (article) is passing the id which is required by the method: :delete method. The later part of the codes adds a confirmation msg.

提交回复
热议问题