In an ERB Rails view
<%= link_to("Destroy", foos_path(1), :method => :delete, :confirm => "Are you sure?") %>
With a link_to like the above you can process the delete for a foo with an ID of 1.
How do make it remote and (a) still control being redirected to a page of my control or (b) call custom JavaScript (the goal of which would be jQuery to refresh a list)
Add
:remote => trueto the link_to will create a remote link.In your controller method at the end put
You can omit the name of the ajax file if it’s the same name as the method.
In my_method.js.erb simply call javascript functions, and you can embed erb ie:
You can redirect to another page using standard javascript/jquery if you choose.