Pierre Wahlgren
Pierre Wahlgren

Reputation: 875

Saving model record not working (Spine)

I'm having problems saving a model record created from the data of a form. Getting the data from the form using <Model>.fromForm(form) works, as it includes all values. However, when I'm saving the record it only saves the cid of the record, nothing else.

This is what the record looks like when logging it:

cid: "c-0"
email: "something"
password: "something"
password2: "something"
username: "something"
__proto__: ctor

What am I doing wrong?

Upvotes: 0

Views: 264

Answers (2)

markmarijnissen
markmarijnissen

Reputation: 5887

I am not using JavaScript myself, but try using @setup instead of @configure

The Spince.js docs say:

@setup(name, [attributes...])

Alternative method for creating a new model class. This is a JavaScript compatibility feature, and shouldn't be used in CoffeeScript.

var User = Model.setup("User", ["first_name", "last_name"])

Upvotes: 0

fholgado
fholgado

Reputation: 390

Are you configuring all the attributes of the model properly? You need to make sure to tell Spine what the model's attributes are like so:

class App.User extends Spine.Model
  @configure 'User', 'account_email', 'default_forwarding_address', 'forwarding_addresses'

I've run into issues where Spine doesn't "save" an attribute just because I forgot to configure it properly. Let me know if that helps!

Upvotes: 2

Related Questions