In my case, I would like to set the defaultValue of a belongsTo relationship to the current user, but can think of other use cases for this.
Would like this functionality also.
aye.
+1
Closing this issue. Now that Ember has Services they are a better place to encapsulating the logic around assigning a "default" relationship on a model.
@bmac Could u explain a little more detailed how to use services this way, please?
+1 on getting a more detailed explanation from @bmac please.
I'd say @bmac is probably suggesting something along these lines:
// app/services/foo.js
export default Ember.Service.extend({
barFor(foo) {
return foo.get('bar') || foo.set('bar', defaultValue())
}
})
I've decided to put this into the adapter, and access it using store.adapterFor('foo').barFor(foo)
Most helpful comment
+1 on getting a more detailed explanation from @bmac please.