Destroy link from scaffold not working #51

timstephenson opened this Issue Mar 18, 2012 · 5 comments


None yet
4 participants

In the scaffold code generated for me, the destroy link was using a GET method so it never hit the destroy method in the controller.

To get it working in my test app I made the following changes:

Copied jqueru_ujs.js from one of my Rails projects to my javascripts folder. Included jquery_ujs.js in the head portion of my layout: app/views/shared/

javascriptTag "/javascripts/jquery_ujs.js"

Changed my link from

linkTo 'Destroy', urlFor(thing, action: "destroy"), "data-method": "delete", "data-confirm": "Are you sure?", "rel": "nofollow" 

I'm not sure if this is the best way, or if it is what is intended, but it seems like it. Is there another file that is already handling it?


lancejpollard commented Mar 19, 2012

Nice solution haha! Didn't even think of the rails.js file… Cool it works.

I had a quick hack in there doing basically what the rails.js file does, grab all links with data-method=delete and convert to ajax POST request with _method='DELETE'. The real solution is coming with Tower.Store.Ajax, which is almost complete.

So for now this is broken and will be fixed in the next release.

Tower.Store.Ajax is a subclass of the memory store handling all the RESTful sync functionality.


sebastianhoitz commented Apr 5, 2012


I today ran into the same issues. What is the current state of this? Is there anything we can help with?




lancejpollard commented Apr 8, 2012

Made a quick example of this when you use the scaffold generator:

# app/client/controllers/
class App.PostsController extends Tower.Controller
  @on "click .post a[data-method='delete']", "destroy"

  # example
  destroy: (event) ->
    row       = $('[data-id]')
    id        = row.attr('data-id')

    App.Post.destroy id, (error, resource) =>


Still working on a cleaner way of doing this, but with that it should work.

Try updating tower with npm install tower in your app and npm install tower -g globally, and grab the latest client-side tower.js, or generate a new app.


lancejpollard commented Aug 21, 2012

A lot has changed since this, see the dev branch. Reopen if there are still issues, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment