Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8884285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:01:34+00:00 2026-06-14T21:01:34+00:00

Using Ember-data and Ember.js, I’m trying to load two models with one JSON request.

  • 0

Using Ember-data and Ember.js, I’m trying to load two models with one JSON request. The models have a relationship analogous to this:

App.Person = DS.Model.extend({
    name:  DS.attr('string'),
    dogs:  DS.hasMany('App.Dog'),
});

App.Dog = DS.Model.extend({
    name:  DS.attr('string'),
    owner: DS.belongsTo('App.Person'),
});

My server is sending JSON like this:

{
    "dog": {
        "id": 1,
        "name": "Fido",
        "owner": {
            "id": 1,
            "name": "John Smith",
            "dogs": [1]
        }
    }
}

…And yet, Ember-data still sends a request (using findQuery) to my server trying to get the owner JSON.

I have a jsFiddle set up that demonstrates it here. To watch the problem happen, you’ll need to go to this link to activate the route/template:

http://fiddle.jshell.net/6kQ8s/2/show/#/dog/1

I haven’t defined findQuery() in my adapter on purpose because I shouldn’t need that to get data that I have already sent… Right?

Does anyone know what I’m doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:01:35+00:00Added an answer on June 14, 2026 at 9:01 pm

    I’m doing the following (using ember-data revision 8)

    App.Dog = DS.Model.extend({
        name:  DS.attr('string'),
        owner: DS.belongsTo('App.Person', { embedded: true }),
    });
    

    Additionally, I have to tell the serializer to load a mapping for this relation.
    Though it’s not required, I’m using my own DS.Serializer subclass. At initialisation
    time the serializer loads a mapping for the Person class, which specifies that
    embedded relationships should be loaded.

      App.WOSerializer = DS.Serializer.extend({
        init: function(){
          this._super();
          this.map(App.Dog, {
            person: {
              embedded: 'load'
            }
          });
      });
    

    Edit by question asker:

    The serializer needed to be initialized in the adapter.

    App.adapter = DS.Adapter.create({
        // ...
        serializer: App.WOSerializer.create()
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Ember Data to define two models and an association between the two,
I am have difficulty setting a belongsTo relationship using ember data. I have a
I'm building a table cell using two bound ember.js views on data. When I
Using ember-data, currently I'm loading data into the controller, on page load, as follows:
I am using Ember.js to create a table from a json feed. I have
I'm using Ember and Ember-data to load a few hundred objects from a REST
I'm loading App.Structure objects using ember-data's fixtures adapter. These objects have embedded App.Overlay objects
I'm using Ember to retrieve JSON data from an API to insert into a
I am using active_model_serializers and ember.js. One of my models has a date attribute.
Explanation: I'm using ember-data for a project of mine and I have a question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.