Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 - link_to with confirm in Rails

I'm trying to customize my dialog confirm the link_to in rails 4. But I do not understand why he rides the html as "confirm", and should be "data-confirm"!

I've tried a number of ways, and it is always generated "confirm", like this:

<%= link_to 'Delete', user, :method => :delete, :confirm => 'Are you sure?' %>

<a confirm="Are you sure?" rel="nofollow" data-method="delete" href="/user/13">Delete</a>

I followed this tutorial: http://thelazylog.com/custom-dialog-for-data-confirm-in-rails/ and i used the example in tutorial, but also doesn't work

like image 648
Mateus Vitali Avatar asked Oct 29 '25 18:10

Mateus Vitali


1 Answers

Confirm has been deprecated in rails 4.

So use new syntax:

<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>
like image 193
Snm Maurya Avatar answered Oct 31 '25 13:10

Snm Maurya