Home » Miscellaneous

[Solution] Ruby on Rails delete confirmation not working

30 May 2016 No Comment

Hello. This is a solution to another problem i faced.

I had this:

<%= link_to ‘Delete’,url_for(action: :delete,id: thing.id),method: :delete, data: {confirm: “Are you sure?”} %>

This should prompt a javascript confirmation with “OK” and “Cancel” buttons. but it won’t work and just goes to the action URL page.
The solution should be to add:

<%= javascript_include_tag :application %>

to your application.html.erb
But if you are on windows you will get this error:

Completed 500 Internal Server Error in 56ms
ActionView::Template::Error (TypeError: Object doesn’t support this property or method
(in C:/path/file.js.coffee)):

There is something wrong with the ‘coffee-script-source’ gem on windows

So the solution is to update your Gemfile with:

gem ‘coffee-script-source’, ‘1.8.’0

And do

bundle update coffee-script-source

You will downgrade the coffee script source gem which works fine with windows.

Your opinion matters!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.