Posts doesn't load comment asyncly


#1

Hi, i am new to ember.I am trying to build this little app where posts belongs to user and also have many comments.

In my posts/post.hbs i have

{{model.user.username}} 
{{#each model.comments as |comment|}}
    {{comment.body}}
{{/each}}

Problem here is, let’s say i visit “myapp/posts/12” , it doesn’t show user’s username nor comments unless i visit users route or comments route separately.It doesn’t fetch posts user or comments unless i visit those routes. How can i solve this?

I tried addin’ asyn:true and async:false option on both corresponding models.

!!!Side question: Is there a backend framework which can be referred to as “best fit for ember” ? & What libraris&add-ons should i use for it?


#2

What data adapter are you using? I had some problems using JSONAPI when I did not provide links http://jsonapi.org/format/#document-links

After including the links in the response JSON EMber Data figured out where to load associations and things worked instantly.

I would recommend Rails with https://github.com/rails-api/active_model_serializers but if you’re more comfortable with other backends use those. Almost all have some sort of support for JSONAPI through gems/packages/libs.

HTH,

Jeroen


#3

In regard to your second question, if you prefer to go the Node route, I would recommend SailsJS. The docs are great, an app is quick to get up and running and it will hopefully be hitting 1.0 in the not-too-distant future.

The downside right now is that there isn’t a complete serializer/adapter library available although sails-json-api-blueprints so you may have to use sails-generate-ember-blueprints with Ember’s RESTAdapter.

Cheers

-Adam