First time poster and extremely new to ember js,rails and would describe myself as a beginner programmer.
I am currently using a nested rails api(and for the moment it cant be changed).It follows a pattern of:
- apiHost/businesses returns all businesses
- apiHost/businesses/business_id returns the business with that id **
- apiHost/businesses/business_id/prices returns the prices in the business
- apiHost/businesses/business_id/prices/prices_id returns the price with the id **
The ** shows the link which a PUT request can be sent to.
I am really struggling of finding a way to accesses the nested elements and from research ember js isn't a fan of nested resources.
I have come across a some websites which look promising but I just cannot seem to get it to work:http://ift.tt/1mRTsCM (maybe my implementation is incorrect or code when doing return....) or I'm not sure of how to implement it Ember JS: Nested api routes
I have added my business model and the price model below.
export default DS.Model.extend({
address: DS.attr('string'),
description: DS.attr('string'),
price: DS.hasMany('price')
});
export default DS.Model.extend({
cost: DS.attr('string'),
description: DS.attr('string'),
business:DS.belongsTo('business')
});
Any help would be greatly appreciated, the first link looks to be promising and perhaps the simplest solution for me.
I am currently using ember cli 2.7
Thank you.
Aucun commentaire:
Enregistrer un commentaire