Last active
December 18, 2015 13:29
-
-
Save BlakeMesdag/5790453 to your computer and use it in GitHub Desktop.
BaconTracker BaconController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaconTracker.BaconController extends Batman.Controller | |
routingKey: 'bacon' | |
index: -> | |
@set 'newBacon', new BaconTracker.Bacon | |
BaconTracker.Bacon.load (err, bacons) => | |
@set 'bacons', BaconTracker.Bacon.get('loaded') | |
createBacon: (bacon) -> | |
bacon.save (err, bacon) => | |
if !err | |
@set 'newBacon', new BaconTracker.Bacon | |
BaconTracker.Bacon.get('loaded').add(bacon) | |
destroyBacon: (bacon) -> | |
bacon.destroy (err, bacon) => | |
if !err | |
BaconTracker.Bacon.get('loaded').remove(bacon) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original code for this guide: BaconTracker – Getting Started with Batman.js and Rails 4