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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:40:13+00:00 2026-06-03T19:40:13+00:00

Normally when I use backbone.js I would apply this sort of patch to nest

  • 0

Normally when I use backbone.js I would apply this sort of patch to nest model attributes the way that Rails expects them:

Backbone.Model.prototype.toJSON = function() { 
  var hashWithRoot = {}; 
  hashWithRoot[this.modelName] = this.attributes; 
  return _.clone(hashWithRoot);
};


App.Models.Card = Backbone.Model.extend({
  modelName:  'card'
});

However, in my current project I’m using Backbone Relational, which is great, but it has its own toJSON override. The result is that I get a circular reference exception in my console:

Uncaught TypeError: Converting circular structure to JSON

Has anyone managed to successfully produce nested JSON for PUT/POST to a Rails backend with Backbone Relational?

EDIT 2:

I created a jsfiddle that shows the collections and models in question – and included some json to bootstrap the app. For some reason (maybe because I’m hungry) I can’t get the fiddle to work.

Hopefully that gives a better idea of what I’m trying to do. I’m going to eat then try to fix the fiddle…

Cheers,
Stu

  • 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-03T19:40:15+00:00Added an answer on June 3, 2026 at 7:40 pm

    Is it uncouth to be writing a non-answer answer? Because I can’t write comments…

    You need to give us more information. I haven’t used Backbone Relational, but I made a fiddle that manages to serialise a model with a HasMany relation. There are some extraneous and incorrect attributes, but no circular structure error.

    What relationships are you using? Can you make a fiddle that is more similar to your application’s structure?

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

Sidebar

Related Questions

Anything I do in views that would normally use ajax to open up a
Where would I normally use this API? In models, URLs, forms, views.py? Where would
I would normally use Google analytics because it is free and simple to implement
I have identified the query constructs my users normally use. Would it make sense
Using win forms with an MVC / MVP architecture, I would normally use a
I normally use this function to sanitize my form inputs before storing them into
I would normally use: if ($(#parkState).val() == 0) { alert(Please select a state.); }
In MVC2 template, I normally use this.ViewData.TemplateInfo.GetFullHtmlFieldId(fieldName) to generate the id field of an
I normally use this step to set up records with factory_girl: Given /^the following
My understanding is that Google Analytics (the tool I'd normally use for website analytics)

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.