Quantcast
Channel: 0xAli`s blog
Viewing all articles
Browse latest Browse all 22

[Solution] Ruby on Rails delete confirmation not working

$
0
0

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.


Viewing all articles
Browse latest Browse all 22

Latest Images

Trending Articles



Latest Images