Misha Moroshko
Misha Moroshko

Reputation: 171341

Ruby on Rails: Why the confirmation message does not appear in "link_to('delete', ...)"?

I have the following link next to one of my products:

<%= link_to("Delete", {:action => 'destroy', :id => product.id}, :class => 'action', :confirm => 'Are you sure?') %>

but when I click it, the confirmation box does not appear.

The generated HTML is:

<a data-confirm="Are you sure ?" class="action" href="/products/destroy/48">Delete</a>

Please advise.

Upvotes: 1

Views: 4797

Answers (3)

ilan weissberg
ilan weissberg

Reputation: 668

try adding it as a data-attribute

data: { confirm: "Are you sure?" }

Upvotes: 1

Brian Rose
Brian Rose

Reputation: 1725

Ensure rails.js is being loaded on the page. The easiest way to accomplish this is with:

javascript_include_tag :defaults

Upvotes: 0

codevoice
codevoice

Reputation: 474

<%= link_to("Delete", product, :method => :delete, :class => 'action', :confirm => 'Are you sure?') %>

check your javascript_include_tag and it should work fine :)

Upvotes: 3

Related Questions