Ruby-on-rails-3 – rails 3: Scaffold Destroy Action Redirects

I created a simple scaffold, the problem is, when I try to delete the record, click destroy rails to redirect to the show action, this is the link code automatically generated when I generate the scaffold :

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

What’s wrong?

You need to include rails.js in the application layout, because this link requires JS to use the correct HTTP method. Also make sure to include csrf_meta_tag in the layout.

I created a simple scaffolding, the problem is, when I try to delete the record, click destroy rails to redirect to the show action, This is the link code automatically generated when I generate the scaffold:

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

What’s wrong?

You need to include rails.js in the application layout because this link requires JS to use the correct HTTP method. Also make sure to include csrf_meta_tag in the layout.< /p>

Leave a Comment

Your email address will not be published.