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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:56:13+00:00 2026-06-17T23:56:13+00:00

I am trying to build a simple application with Ember js on the frontend

  • 0

I am trying to build a simple application with Ember js on the frontend and I have a RESTful server running on the server that returns JSON representations of database tables.

The database has three tables: users, accounts, transactions. The application works kind of like a bank account. A user hasMany accounts, an account belongsTo a user and hasMany transactions, a transaction belongsTo an account.

My models are described like this

// Models
App.Store = DS.Store.extend({
  revision: 11,
  adapter: DS.RESTAdapter.create({
    url: 'http://api.mydomain.ca'
  })
});

App.User = DS.Model.extend({
    firstName: DS.attr('string'),
    lastName: DS.attr('string'),
    accounts: DS.hasMany('App.Account')
});

App.Account = DS.Model.extend({
    ownedBy: DS.belongsTo('App.User'),
    transactions: DS.hasMany('App.Transaction')
});

App.Transaction = DS.Model.extend({
    account: DS.belongsTo('App.Account'),
    amount: DS.attr('number'),
    description: DS.attr('string'),
    timestamp: DS.attr('date')
});

My Controllers:

//Controllers
App.UserController = Ember.ObjectController.extend();

App.AccountsController = Ember.ArrayController.extend();

App.TransactionsController = Ember.ArrayController.extend();

and my Routes:

// Router
App.Router.map(function() {
    this.resource('users', function() {
        this.resource('user', {path:':user_id'});
    }); // '/#/users/:user_id'
});

App.IndexRoute = Ember.Route.extend({
    redirect: function() {
        this.transitionTo('users');
    }
});

App.UsersRoute = Ember.Route.extend({
    model: function() {
        return App.User.find();
    }
});

App.UserRoute = Ember.Route.extend({
    model: function(params) {
        return App.User.find(params.user_id);
    },
    setupController: function(controller, model) {
        this.controllerFor('accounts').set('model', App.Account.find({ownedBy:model.id}));
    }
});

I’m using a master – detail layout. When you visit my application at ‘/users/3’ it shows a list of users on the left and the details for user 3 on the right. In the details I want to be able to show the account number, account balance and a list of the transactions.

So here’s something I’m not sure about. My database users table has id, first_name, and last_name. It made sense for me to put the relationship between accounts and users in the accounts table rather than have to maintain a list of accounts in the users table. My accounts table has an id field and a owned_by field that has the id of the user that owns the account. The same is true for my transactions table. Rather than the having to maintain a list of transactions in the account I have an account field in the transactions table that holds the id of the account for that transaction. This is how it made sense to me but I’m not sure if this is appropriate for the way Ember expects data.

I was able to connect the accounts to the user in the setupController method of my user route using this:

this.controllerFor('accounts').set('model', App.Account.find({ownedBy:model.id}));

but I don’t know how to link the transactions to the account.

Can anybody help me out with this? 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-17T23:56:14+00:00Added an answer on June 17, 2026 at 11:56 pm

    If you follow the convention and structure your Json response accordingly you don’t have to do any wiring and your object will be deserialized properly

    Here’s an example, sideloading your accounts and transactions

    {
      "user": {
        "id": 1,
        "first_name": "john doe",
        "accounts": [1, 2]
      },
    
      "accounts": [{
        "id": 1,
        "transactions": [1, 2, 3]
      },
      {
        "id": 2,
      }],
    
      "transactions": [{
        "id": 1,
      },
      {
        "id": 2,
      },
      {
        "id": 3,
      }]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to build a simple application in python, where I have tags that
I'm trying to build a simple GAE application that would read a textbox, pass
I'm trying to build a simple ember application (filebrowser) using an AMD approach (yes
I'm trying to build a simple adobe air application that reads an rss feed.
I'm trying to build simple facebook application with 4.2.1 C# SDK. But I have
i am trying to build simple web server, that able to transfer files. I
In my rails application I'm trying to build a simple FAQ page that has
I'm trying to build a rather simple Windows Application for the employees that process
I'm trying to build a simple Windows Forms application that can query the capabilities
I am trying to build a simple booking application for a school presented as

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.