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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:09:43+00:00 2026-05-30T18:09:43+00:00

I am newbie in client side Javascript MVC, first ember.js app. I follow the

  • 0

I am newbie in client side Javascript MVC, first ember.js app.

I follow the instructions here to use ember-rest in creating a post-comments type of nested models.

http://www.cerebris.com/blog/2012/01/26/beginning-ember-js-on-rails-part-2/

I started writing nested resources as follow:

  resources :conversations do
    resources :comments
  end

Now the problem is when I had to write the ember-rest controller:

App.commentsController = Ember.ResourceController.create({
resourceType: App.Comment
resourceURL: ‘/conversations/:id/comments’
});

I don’t think I can use the :id in the middle; how could I work around that? Does ember-data solves this? It seems spine.js integration will be slightly easier to handle this. Thanks in advance!

  • 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-05-30T18:09:45+00:00Added an answer on May 30, 2026 at 6:09 pm

    I’ve been meaning to answer your comment on my post from yesterday, so I’m glad you asked the question here.

    I should start by saying that I wrote ember-rest as a very thin layer over jQuery.ajax. It’s not terribly advanced, and there is not even a built-in facility for associations. However, I am considering adding one now that this lib is getting a fair bit of use. As you’ll see from the code below, this concept can be handled but should be better abstracted in the lib.

    Associations can be handled by creating an instance of a resource controller within each parent resource. Each particular resource controller should manage a particular array of resources, but not necessarily all the resources of a particular type.

    In your case, you could extend ResourceController to manage comments for conversations:

      App.ConversationComments = Ember.ResourceController.extend({ 
        resourceType: App.Comment,
    
        // override _resourceUrl() to base the url on the conversation
        _resourceUrl: function() {
          return this.get("conversation")._resourceUrl() + "/comments";
        }
      });
    

    You could then configure an instance of ConversationComments for each conversation:

      App.Conversation = Ember.Resource.extend({
        resourceUrl:        '/conversations',
        resourceName:       'conversation',
        resourceProperties: ['prop1', 'prop2']
    
        // init comments
        init: function() {
          this.set("comments", App.ConversationComments.create({ conversation: this }));
        }
      });
    

    Last but not least, you’ll need to retrieve the comments for each conversation:

      conversation.get("comments").findAll();
    

    If you have all the comments in json, you could alternatively use loadAll(). Where and when you call loadAll() or findAll() depends on your app’s needs. Obviously, you will want to reduce the number of ajax calls for best performance.

    Ember-data is a much more ambitious project than ember-rest, and already has support for associations as well as advanced features such as transactions. With that said, it’s under very active development with a changing API. If you’re patient and willing to dig into the code, I highly recommend trying it out. When the dust settles a bit, I also plan to blog about it.

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

Sidebar

Related Questions

I'm a drupal newbie... I completed my first drupal site. then client wanted to
I'm newbie with ext js, a client wants me to use it in some
Newbie question. Why is this JavaScript function returning undefined? var redis = require(redis), client
Python and django newbie question, here is code: class Client(User) #some fields client=Client() client.save()
I'm kind of newbie in C#.net . Im doing a form post on Client
I'm a newbie when it comes to client/server app. (I only programmed asp.net apps)
(I've removed client name because of NDA) Java/JSP newbie here. I have a JSP
Complete newbie question here: I'm just playing with C# for the first time and
Ruby newbie here trying to figure out how to use a Gem and thus
I'm a socket programming newbie. Here's a snippet: struct sockaddr_storage client_addr; ... client_addr_size =

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.