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 9146149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:41:02+00:00 2026-06-17T10:41:02+00:00

I have two models defined in Ember and also in a Rails application: App.Library

  • 0

I have two models defined in Ember and also in a Rails application:

App.Library = DS.Model.create({
  books: DS.hasMany('App.Book')
});
App.Book = DS.Model.create({
  library: DS.belongsTo('App.Library')
});

On the back-end side, I have several Book for each Library, I would like to retrieve those books but there is no back-end call when I do this (library object is correct and has an id that match its id on the back-end):

var libraryBooks = library.get("books");

I am expecting a back-end call to my rails API in order to fetch all books for this specific library, but instead I just get the empty Ember.OrderedSet without back-end call.

I am starting with Ember so maybe this is not correct, if this is the case, what is the best way to retrieve the “hasmany” for a given model directly from the back-end if you only have the model’s id?

  • 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-17T10:41:03+00:00Added an answer on June 17, 2026 at 10:41 am

    .find() will make ember do a request.

    App.Library.find(1/* the id of the library*/).get('books');
    

    it’ll to a request to /librarys/1 i think. You can configure the plural like this:

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

    Now the request will be to /libraries/1

    You could also probably get the books by the library:

    App.Book.find({library: 1});
    

    the library: 1 you’ll have to handle yourself on the backend. emberdata sends it as a querystring. Like this: /books?library=1

    Have a look here there is some documentation on ember-data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models: Play and PlayParticipant , defined (in part) as: class PlayParticipant(models.Model):
So I have two models, a Ranking model and a UserRanking model. The app
In a Rails 3.2 app I have two user models set up using Devise:
I have a Rails 2.3.11 app which has two key Models: Activity Transaction Live
I have two models defined loosely like this: class InformationUnit(models.Model): username = models.CharField(max_length=255) project
I have two models, Category and Point . The associations are defined as: Category
In this situation I have two models, Comment and Score. The relationship is defined
I have two models: class Contact(models.Model): name = models.CharField(max_length=255) class Campaign(models.Model): contact = models.ForeignKey(Contact,
I have two models like this: class ClassA(models.Model): ida = models.AutoField(primary_key=True) classb = models.ForeignKey(ClassB)
I have two models in my Django application, for the purposes of storing search

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.