How to delete with ajax

Hello, I’m trying to create a link to delete the record of a discount
in my database. I have a page that lists them, each one rendered in a
partial with a delete link. I’m trying link_to_remote, but it gives me
this errors:

No method responded to 28 (which is the record id)

Here is a link to my code:

http://pastie.org/private/s1m8ddsb27fyad8z1rhyg

Try adding a :method => :delete to the link. If you’re using default
resource routes, that should do the trick (also you don’t need to
use :action => ‘destroy’, but can instead pass discount_url(discount)
as :url.

– niklas

Are you on Rails3 (can’t access pastie from mobile)?
<%= link_to ‘destroy’, product, :confirm => ‘Are you sure?’, :method =>
:delete, :remote => :true %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs