Rails 3: scaffold destroys an action redirecting an action to show an action

I created a simple scaffold, the problem is that when I try to delete the record, click "drag rails" on the show action, this is the link code generated automatically when I create the scaffold:

<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> 

what's wrong?

+3
source share
3 answers

You should have the rails.jsapplication included in your layout, as this link requires JS to use the correct HTTP method. Also make sure what you have csrf_meta_tagin your layout.

+5
source

Check if application.js //= require jquery_ujs

+2
source

application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
0

All Articles