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

  • Home
  • SEARCH
  • 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 9111931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:37:01+00:00 2026-06-17T03:37:01+00:00

Using: Ember commit a5d45f66e1 from Jan 3, 2013) Ember-Data commit 508479dee7 from Jan 4,

  • 0

Using:

  • Ember commit a5d45f66e1 from Jan 3, 2013)
  • Ember-Data commit 508479dee7 from Jan 4, 2013

Similar to this question (‘Unable to get hasMany association’), I am unable to access embedded hasMany records directly but can see them through the model’s content attribute.

For JSON:

{
   "ref_book_search":{
      "query":"har",
      "results":[
         {
            "publisher":{
               "name":"Pangolin",
               "created":"2012-09-10T18:38:27.259515",
               "id":"3d2028e4fb91181e1a6e012313914f821",
               "is_active":true,
               "main_url":null,
               "resource_uri":"/api/v1/ref_publisher/3d2028e4fb91181e1a6e012313914f821"
            },
            "genre":"romcom",
            "id":"cc671f00fc2711e1e41612313914f821",
            "resource_uri":"/api/v1/ref_book/cc671f00fc2711e1e41612313914f821",
            "title":"Harry Placeholder and the Goblet of PBR"
         },
         {
            "publisher":{
               "name":"Hoof & Mouth",
               "created":"2012-10-10T14:31:27.259515",
               "id":"3d200e9afb9811e1a27417383914f821",
               "is_active":true,
               "main_url":null,
               "resource_uri":"/api/v1/ref_publisher/3d200e9afb9811e1a27417383914f821"
            },
            "genre":"horror",
            "id":"cc621f08fc2711e1b81612313914e821",
            "resource_uri":"/api/v1/ref_book/cc621f08fc2711e1b81612313914e821",
            "title":"Harvey Weinstein Holiday Cookbook"
         }
      ]
   }
}

And app.js (note the map statements, which were the solution suggested in the prior question):

var App = Ember.Application.create();

DS.RESTAdapter.configure("plurals", {"ref_book_search" : "ref_book_search"});

App.store = DS.Store.create({
  revision: 11,
  adapter: DS.RESTAdapter.create({
    bulkCommits: false,
    namespace: "api/v1"
  })
});

DS.RESTAdapter.map('App.RefBookSearch', {
  primaryKey: 'query'
});

App.store.adapter.serializer.map('App.RefBookSearch', {
  results: {embeddded: 'load'}
});

App.store.adapter.serializer.map('App.RefBook', {
  publisher: {embeddded: 'load'}
});

App.RefPublisher = DS.Model.extend({
  name : DS.attr('string'),
  created : DS.attr('date'),
  isActive : DS.attr('boolean'),
  mainUrl : DS.attr('string')
});

App.RefBook = DS.Model.extend({
  publisher: DS.belongsTo('App.RefPublisher'),
  title : DS.attr('string'),
  genre : DS.attr('string')
});

App.RefBookSearch = DS.Model.extend({
  query: DS.attr('string'),
  results: DS.hasMany('App.RefBook')
});

App.Router.map(function(match) {
  match('/').to('query'),
  match('/query/:ref_book_search_id').to('query')
});

App.QueryController = Ember.Controller.extend({
  bookSearch: null,
  results: []
});

App.QueryRoute = Ember.Route.extend({
  setupControllers: function(controller, refBookSearch) {
    controller.set('bookSearch', refBookSearch)
    controller.set('results', refBookSearch.get('results').content)
  }
})

App.initialize();

Everything looks fine at first, just like other poster:

search = App.RefBookSearch.find('ha')
search.get('query')
// => "ha"
results = search.get('results')
results.get('firstObject') instanceof App.RefBook
// => true

But then:

results.forEach(function(result) { console.log(result.get('title')) })
// => TypeError: Cannot call method 'hasOwnProperty' of undefined

Accessing via content shows the data is there:

results.content.forEach(function(result) { console.log(result.title) })
// => Harry Placeholder and the Goblet of PBR
// => Harvey Weinstein Holiday Cookbook

Now if I try accessing directly again, I get a slightly different error:

results.forEach(function(result) { console.log(result.get('title')) })
// => undefined x 2

This may or may not be related to this bug filed a few days ago.

I feel like I’ve tried everything here; I hope I’m just missing something simple. Any pointers very much appreciated. Thanks.

  • 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-17T03:37:02+00:00Added an answer on June 17, 2026 at 3:37 am

    This is what ultimately worked for me. There seems to be some order-of-operations sensitivity i.e., doing the configure and map before creating the store. Also note that adapter.map is a convenience function that performs the mapping on the serializer.

    App.Adapter = DS.RESTAdapter.extend()
    
    App.Adapter.configure("plurals", {
      "ref_book_search" : "ref_book_search",
      "ref_book" : "ref_book",
      "ref_publisher" : "ref_publisher"
    });
    
    App.Adapter.configure('App.RefBookSearch', {
      primaryKey: 'query'
    });
    
    App.Adapter.map('App.RefBookSearch', {
      results: {'embedded': 'load'}
    });
    
    App.Adapter.map('App.RefBook', {
      publisher: {'embedded': 'load'}
    });
    
    App.store = DS.Store.create({
      revision: 11,
      adapter: App.Adapter.create({
        bulkCommits: false,
        namespace: "api/v1"
      })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using: ember.js commit b2e82ae ember-data.js commit 001ba0c handlebars-1.0.rc.2.js This used to work already with
I'm using Ember and Ember-data to load a few hundred objects from a REST
I'm using Ember to retrieve JSON data from an API to insert into a
Explanation: I'm using ember-data for a project of mine and I have a question
I'm using Ember built from git master. My RouteManager is not complex, but when
I'm building a table cell using two bound ember.js views on data. When I
Using ember data, I've run across an issue during serialization where computed properties are
Using the last version of ember-js and ember-data, I got an issue when deleting
I am building a project management app using ember.js-pre3 ember-data revision 11. How do
I am have difficulty setting a belongsTo relationship using ember data. I have a

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.