Skip to content

Instantly share code, notes, and snippets.

@DavertMik
Created February 8, 2013 15:33
Show Gist options
  • Save DavertMik/4739732 to your computer and use it in GitHub Desktop.
Save DavertMik/4739732 to your computer and use it in GitHub Desktop.
Batman.js destroying resources
class YourApp.PostsController extends Batman.Controller
# other controller actions
index: ->
show: ->
new: ->
create: ->
update: ->
# not routable, an event
# the first parameter is passed object
destroy: (post, node, event)->
post.destroy (err) =>
if err
throw err unless err instanceof Batman.ErrorsSet
else
YourApp.flashSuccess "Removed successfully!"
@redirect '/emails'
<a data-event-click="controllers.postsController.destroy | withArguments post">DELETE POST</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment