Wednesday 15 July 2015

javascript - Accessing rails relationships with Ember.js -


I am just starting to learn amber and writing a simple app that reads from the database, I can use it with fixtures I have got to work, how I want to, and have just started reading some progress from a database. My problem now is that I can not reach the elements of children - I have a parent class which I am responding to with Jasonson through the series, and I am serving children's elements in the JSN request. However, I do not know where to go from here to get the parents class in Amber to read and display the elements of children. It can understand something else with the code below.

Let me know if you need any other code - this is not a specific description of all standard amber codes! The only lead on which I am going to serve as my current nested Ruby routes is as Segment /: id / boots /: id when the data usage of Amber loads loads data cohorts /: id /: id :)

Model:

  Plato.boot = DSMold.andend (name: DS.ttr ("string"), platoon: DS Belong ('Plato. Cohort'), Centers: DSHSMoney ('Plato Hub')) Plato Cohort = ds Model Aid (name: DS.ttr ('string'), boot: DSHASMAI ('Plato.boot'))   

Route.rb

  root To: 'Application # Index' resources: Do the cooperative resources: End of Boots Resources: Boot   

Ploten (Guardian) Controller

  Class CohortsController & Lt;   

boot (child) controller

  code> class boots controller & lt; ApplicationController response_to: Boot.all end df show with json dnf index number response_with Boot.find (params [: id]) and end   

router.jscafie

 < Code> Plato.Router.map () - & gt; This.resource ('cohorts', - & gt; this.resource (' cohort ', {path:' /: cohort_id '}, - & gt; this.resource (' boot ', {path:' boots /: boot_id '}))) Plato.CohortsRoute = Ember.Route.extend (Model: -> Plato.Cohort.find ()) Plato.BootsRoute = Ember.Route.extend (Model: -> Plato.boot.on (Parameters))    

Did you set your embedded record to boot Have tried to define the router map?

For example:

  Plato. Adapter = ds .RESTAdapter.extend (); Plato Store = ds. Store Extensions ({Adapters: Plato Adapters}); Plato Adapter.map ('plato cahort', {shoes: {embedded: 'always'}});   

In this way embedded records will be loaded together with the parents record.

Hope it helps.

No comments:

Post a Comment