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:
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?
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.
I today ran into the same issues. What is the current state of this? Is there anything we can help with?
Made a quick example of this when you use the scaffold generator:
class App.PostsController extends Tower.Controller
@on "click .post a[data-method='delete']", "destroy"
destroy: (event) ->
row = $(event.target).closest('[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.
npm install tower
npm install tower -g
A lot has changed since this, see the dev branch. Reopen if there are still issues, thanks!