Mateus Vitali
Mateus Vitali

Reputation: 159

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

Upvotes: 4

Views: 3609

Answers (2)

installero
installero

Reputation: 9776

To get the same behavior in rails 7 you should use turbo_confirm key instead:

<%= link_to 'Delete', user,
  data: {turbo_method: :delete, turbo_confirm: 'Are you sure?'} %>

Upvotes: 1

Inx Maurya
Inx Maurya

Reputation: 1155

Confirm has been deprecated in rails 4.

So use new syntax:

<%= link_to "title", "#", data: {confirm: "Are you sure!"} %>

Upvotes: 12

Related Questions