Rails: confirmation does not display a dialog box

I have a rails application with the following code in one of my views:

<% if @present.taken == false %>
    <%= link_to "I want to buy this present", :confirm => 'Are you sure you want to buy this present?', :action => "taken_toggle", :id => @present.id %>
<% end %>

However, I do not see the javascript dialog showing - it seems that to skip this bit (the action call is valid).

My application layout has the following:

  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>

So, I think I have the necessary javascript loaded.

Any ideas why this is not working?

+3
source share
1 answer

As shown in the documentation,

http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

at

Be careful when using the old argument style, since an additional literal hash is needed:

try using like this

<% if @present.taken == false %>
    <%= link_to "I want to buy this present", { :action => "taken_toggle"}, :confirm => 'Are you sure you want to buy this present?', :id => @present.id %>
<% end %>
+8
source

All Articles