4

I'm trying to set default types in an Ember Model, but only some types work:

  createdDate: DS.attr('date', {defaultValue: new Date()}) // Works
  createdDate: DS.attr('boolean', {defaultValue: false}) // Works
  createdDate: DS.attr('string', {defaultValue: "example"}) // Doesn't work - attribute null
  createdDate: DS.attr('number', {defaultValue: 99}) // Doesn't work - attribute null

What am I missing?

Undistraction
  • 42,754
  • 56
  • 195
  • 331

1 Answers1

1

According to here, all your code is fine. However, looks like the defaultValue only handles the undefined cases (your boolean and date). You may try to handle those null cases with a function you'll pass a second argument.