Created
July 30, 2016 21:07
-
-
Save visualjeff/152ddde6922b5ae75285cbc841888acb to your computer and use it in GitHub Desktop.
Mirage cheatsheet
This file contains hidden or 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
Mirage cheatsheet: | |
1. Install Mirage: ember install ember-cli-mirage | |
2. Set namespace in mirage/config.js | |
3. Set route handler in mirage/config.js | |
4. Generate mirage model. ember g mirage-model <model_name> | |
5. If you not using JSONAPI. Customize your mirage serializer | |
6. Seed the database: ember g mirage-fixture <fixture_name> | |
7. Remove senarios directory. It prevents fixtures being load. rm -rf senarios | |
8. Refactor to use shorthands where possible. | |
this.get('/bands', function(schema, request) { | |
return schema.bands.all(); | |
}); | |
this.post('/bands', function(schema, request) { | |
let attrs = JSON.parse(request.requestBody).band; | |
return schema.bands.create(attrs); | |
}); | |
Becomes: | |
this.get('/bands'); | |
this.post('/bands'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment