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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:06:41+00:00 2026-06-18T09:06:41+00:00

I’m using Ember 1.0-pre4. I have two models in one-to-one relationship: App.Lesson = DS.Model.extend

  • 0

I’m using Ember 1.0-pre4.

I have two models in one-to-one relationship:

App.Lesson = DS.Model.extend                               
  timeslot: DS.belongsTo 'App.Timeslot'

App.Timeslot = DS.Model.extend
  lesson: DS.belongsTo 'App.Lesson'

I have an adapter configured to embed timeslot into lesson upon saving:

App.Adapter = DS.RESTAdapter.extend()  

App.Adapter.map App.Lesson,    
  timeslot: { embedded: 'always' }             

App.Store = DS.Store.extend            
  revision: 11                                 
  adapter: App.Adapter.create()       

Then I create a lesson and a time slot and try to save them:

lesson = App.Lesson.createRecord
  group: group
lesson.set('timeslot', App.Timeslot.createRecord())

lesson.store.commit()

But upon saving nothing is embedded and I see to POST requests, one for lesson and one for timeslot.

How do I tell Ember to always embed timeslot into lesson?

  • 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-18T09:06:43+00:00Added an answer on June 18, 2026 at 9:06 am

    I think this is a bug and you should report it. Sifting through the source code and doing some tests reveals that createRecord does not take into account the embedded configuration at all. This configuration is only used for the serialization and deserialization process.

    When you make a call to createRecord, a record is added to a bucket, created, and on commit ember-data simply fires an ajax post on every record in the bucket.

    So to get back to your code, to ember-data, you created two records and on commits it will fire an ajax post call for the Lesson object with Timeslot embedded in it, AND will also, in a subsequent call, fires another ajax post for Timeslot, the last remaining record in the bucket.

    lesson = QrTimetable.Lesson.createRecord
      group: group
    
    lesson.set('timeslot', QrTimetable.Timeslot.createRecord())
    lesson.store.commit()
    

    Unless, someone with better understanding of the inners of ember-data contradicts my point, i tend to believe that, again, that this is a bug.

    Here’s the last code called when you commit the transaction.

      createRecord: function(store, type, record) {
        var root = this.rootForType(type);
    
        var data = {};
        data[root] = this.serialize(record, { includeId: true });
    
        this.ajax(this.buildURL(root), "POST", {
          data: data,
          context: this,
          success: function(json) {
            Ember.run(this, function(){
              this.didCreateRecord(store, type, record, json);
            });
          },
          error: function(xhr) {
            this.didError(store, type, record, xhr);
          }
        });
      },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.