nicklandgrebe / active-resource.js

ActiveResource.js - API resource relational mapping in JavaScript
https://active-resource.js.org
MIT License
133 stars 20 forks source link

Problem with PATCH (update/save calls) #22

Closed arlaneenalra closed 7 years ago

arlaneenalra commented 7 years ago

I've noticed that updates to a previously loaded objects don't push changed attributes. It took a bit of work, but I've traced down to the fact that <object>.klass().fields() does not contain any of the assigned attribute values.

screen shot 2017-10-12 at 1 12 42 pm

The class definition looks something like:

import ApiLibrary from "./module.js";

export default class Objective extends ApiLibrary.Base
{

}

Objective.className = "Objective";
Objective.queryName = "objectives";

Objective.hasMany("objective_channels");

ApiLibrary.Objective = Objective;

I've also discovered that adding the undocumented call to Objective.attributes("name", "decription"); makes things work.

Is this a bug or something missing from the documentation?

Note, create works fine. It's just update that's blowing up on me. (I tried with the release 0.9.5 and the 0.9.6 Release commit directly from the repo...)

greywolvez commented 7 years ago

This is just missing from the documentation, I posted an issue about this very thing and it is simply missing from the documentation.

See https://github.com/nicklandgrebe/activeresource.js/issues/21

nicklandgrebe commented 7 years ago

Just updated the docs. Thanks for your patience