Based on this tutorial.
ember new bookstore
Update bower.json
"ember": "2.0",
"ember-data": "2.0"
ember generate resource books title:string price:number author:belongs-to publisher:belongs-to
ember g resource authors name:string books:has-many
ember g resource publishing-houses name:string discount:number books:has-many
ember g adapter application
ember g serializer application
app/adapters/application.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend();
app/serializer/application.js
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend();
Make sure that your Rails Api app is already running
ember server --proxy http://localhost:3000
ember g model publisher
app/router.js
Router.map(function() {
this.route('books', { path: '/' });
this.route('author', { path: '/author/:author_id' });
});
Download model in router
app/routes/books.js
model() {
return this.store.findAll('book');
}
Add a list in templates/books.hbs
<ul>
{{#each model as |book|}}
<li>
<strong>{{book.title}}</strong> <em>by</em> {{book.author.name}}
</li>
{{/each}}
</ul>
ember-cli-sass repo: link ember-cli-bootstrap-sassy repo: link
ember install ember-cli-sass
ember install ember-cli-bootstrap-sassy
- Add
navbarpartial. - Add container to
application.hbsand boxes tobooks.hbs - Add extra styles to
styles/app.scss
- Create
routes/author.js - Create
templates/author.hbs
Create a books controller.
ember g controller books
- Update
routes/books.js - Update
controllers/books.js - Insert limit buttons in
templates/books.hbs
You will need the following things properly installed on your computer.
git clone <repository-url>this repository- change into the new directory
npm installbower install
ember server- Visit your app at http://localhost:4200.
Make use of the many generators for code, try ember help generate for more details
ember testember test --server
ember build(development)ember build --environment production(production)
Specify what it takes to deploy your app.