Giter Club home page Giter Club logo

Comments (6)

ebryn avatar ebryn commented on June 2, 2024

Can you provide more details? Perhaps a JSBin showing what you're experiencing? What you describe should work just fine.

from ember-model.

jgaskins avatar jgaskins commented on June 2, 2024

It works when I reload the page, but it's not returning the value to the running app. Maybe I'm just not doing it properly, but I couldn't find any documentation on how it's meant to work. I'll try to get a JSBin up for you.

from ember-model.

jgaskins avatar jgaskins commented on June 2, 2024

Looks like I was indeed doing something wrong. I'm not sure what yet, but it's working in the example app (code here) I just created. Well … partially. It returns the tags (generated on the server) to the client, but not the id of the created object. The links to the just-created objects have ids of "undefined", despite being part of the JSON object returned from the POST request.

Hilariously, clicking between the links works even though there may be multiple objects have that "undefined" id. Unfortunately, those URLs don't work when you reload the page so if you share the "undefined" link with someone else or bookmark it, it won't be the right thing.

from ember-model.

lagartoflojo avatar lagartoflojo commented on June 2, 2024

@jgaskins I think you are missing id: Ember.attr() in your Article model.

from ember-model.

jgaskins avatar jgaskins commented on June 2, 2024

That does make the id work, however an explicit id isn't necessary when you get the data from a GET request, which seems inconsistent and adds to my confusion. :-)

Also, I added a belongsTo to the Article model in this sample app to simulate the server attaching the currently signed-in user to the article as the author (this is behavior I need in my real app). This doesn't seem to be handled in the running app until the page reloads even though the relationship is explicit in the model.

Something I'm wondering about, I'm using links.author to specify the relationship in JSON, as mentioned on the json-api.org documentation, rather than the author_id as mentioned in the Ember Model readme. Could the fact that it's contained within a nested document be part of the problem?

from ember-model.

ebryn avatar ebryn commented on June 2, 2024

Closing due to inactivity. Please reopen if this is still an issue.

from ember-model.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.