This assumes you've gone through ASH's Ember setup documentation. If you have not or need this information, contact the Front End Team.
To get started, clone this repo locally and ember init. Each branch will take you through subsequent steps.
- Generate a
hotelmodel and add the attributes:name:string,price:number,favorite:boolean, anddetails:string. - In the hotel route, remove the hard-coded object and instead return hotel model from the Ember data
storeobject. Hint: You need to get allhotelrecords. - Install the
ember-cli-miragelibrary. - Generate a mirage factory for
hotelthen set it up to generate fake data usingFakerforname,price,favorite, anddetails. When setting this up, the types of the data generated should correspond to the model types we defined in thehotelmodel. More onFaker.js: https://github.com/marak/Faker.js/ - In the mirage scenarios file, create 10 records named
hotel. - In the mirage config file, add a handler to request of type
getto the/hotelsendpoint. Make surehotelsis pluralized. - Homework from last session: Add Ember Data & models to the restaurants route. Also, add a mirage factory for the restaurant route to generate fake data.
- Bonus Homework: Read about creating nested relationships within Ember data models.
- Can you name few attribute types used when defining our models?
- We retrieved the
hotelmodel withstore.findAll('hotel'). How does Ember know how to make a get request to the/hotelsendpoint? - How do we make mirage handle API requests such as
GET,SET,PUT, andDEL? What about passing params to the endpoint?
- Make sure you have git setup on your computer
- Create a folder on your local computer that will eventually hold this project (the rest of the steps should be done in the command line in that folder)
git clone https://github.com/ASHdevelopment/Ember-Lunch-and-Learn.gitcd Ember-Lunch-and-Learnto move into the folder that was downloadedember init. Do not overwrite any of the files when prompted.- If this is NOT your first time working in this project and you want to preserve the work you've already done, only select
Yesto overwrite the following files:app/index.html,test/index.html,config/environment.js,package.json,bower.json, andREADME.md. ember swill start the project locally inhttp://localhost:4200. Open http://localhost:4200 to make sure it's working.
ember g = ember generate
ember s = ember serve