PDA

View Full Version : [CLOSED]cannot extend Model having associations (PR5)



christophe.geiser
30 Mar 2011, 2:19 AM
Trying to extend User Model as below triggers a 'config.ownerModel is undefined' error. It seems that Ext.data.Association.constructor is called without config while overriding Model.


Ext.regModel('Post', {
fields: ['id', 'user_id'],
belongsTo: 'User',
hasMany : {model: 'Comment', name: 'comments'}
});

Ext.regModel('Comment', {
fields: ['id', 'user_id', 'post_id'],
belongsTo: 'Post'
});

Ext.regModel('User', {
fields: ['id'],
hasMany: [
'Post',
{model: 'Comment', name: 'comments'}
]
});

Ext.regModel('UserExtend',{
extend: 'User'
});

Cheers
c.

evant
30 Mar 2011, 6:33 PM
If I run your code against B1 no errors are thrown. Can you confirm?

christophe.geiser
30 Mar 2011, 11:42 PM
Congrats to the team for the Beta !

I can confirm: this problem does not persist under B1

Cheers
C.

evant
31 Mar 2011, 12:05 AM
FYI there's no reason to use regModel anymore, you can extend directly:



Ext.define('Foo', {
extend: 'Ext.data.Model',
fields: ['bar', 'baz']
});


This means you can declare your models like any other classes.