Here is some more information regarding the bug with hasMany:
Models:
Code:
Ext.regModel("Store", {
fields: [
{name: "id", type: "int"},
{name: "name", type: "string"},
{name: "email", type: "string"},
{name: "phone", type: "string"},
{name: "hashed_password", type: "string"}
],
validations: [
{type: 'presence', field: 'hashed_password'},
{type: 'presence', field: 'name'},
{type: 'length', field: 'hashed_password', min: 4},
{type: 'format', field: 'email', matcher: /^[^@][\w.-][email protected][\w.-]+[.][a-z]{2,4}$/i}
],
associations: [
{type: 'hasMany', model: 'Deal', name: 'deals'},
{type: 'hasMany', model: 'Earn', name: 'earns'},
{type: 'hasMany', model: 'Reward', name: 'rewards'}
],
});
/**
* @class Deal
* @extends Ext.data.Model
*/
Ext.regModel("Deal", {
fields: [
{name: "id", type: "int"},
{name: "name", type: "string"},
{name: "store_id", type: "integer"},
{name: "description", type: "string"},
{name: "thumbs_up", type: "integer"},
{name: "thumbs_down", type: "integer"}
],
validations: [
// {type: 'presence', field: 'hashed_password'}
],
belongsTo: 'Store'
});
I ommited the other two for brevity
Requested JSON Data:
Code:
{
"stores": [
{
"name": "Jeffs store",
"created_at": "2010-12-28T10:04:08Z",
"updated_at": "2011-01-19T00:39:44Z",
"hashed_password": "67ea66ac0f272be8aac494de523892bf0bb646b7",
"id": 1,
"network": "ubc",
"area": null,
"rewards": [
{
"name": "Reward 1",
"created_at": "2011-01-21T08:56:39Z",
"updated_at": "2011-01-21T08:56:39Z",
"store_id": 1,
"id": 1,
"points_required": 1
},
{
"name": "Reward 2",
"created_at": "2011-01-24T22:02:45Z",
"updated_at": "2011-01-24T22:02:45Z",
"store_id": 1,
"id": 2,
"points_required": 2
}
],
"phone": "23123",
"registered_at": "2010-12-28T10:03:00Z",
"deals": [
{
"name": null,
"created_at": "2010-12-29T04:25:13Z",
"updated_at": "2011-01-21T08:28:04Z",
"store_id": 1,
"id": 1,
"active_date": null,
"thumbs_down": null,
"description": null,
"thumbs_up": null,
"created": null
},
{
"name": "My deal",
"created_at": "2010-12-29T04:28:06Z",
"updated_at": "2010-12-29T04:28:06Z",
"store_id": 1,
"id": 2,
"active_date": "2010-12-29T04:27:00Z",
"thumbs_down": null,
"description": "dealie",
"thumbs_up": null,
"created": null
},
{
"name": "HEfd",
"created_at": "2010-12-29T04:33:29Z",
"updated_at": "2010-12-29T04:33:29Z",
"store_id": 1,
"id": 3,
"active_date": "2010-12-29T04:33:00Z",
"thumbs_down": null,
"description": "sdsdd",
"thumbs_up": null,
"created": null
},
{
"name": "Ssdsd",
"created_at": "2011-01-09T07:34:55Z",
"updated_at": "2011-01-09T07:34:55Z",
"store_id": 1,
"id": 4,
"active_date": "2011-01-09T07:34:00Z",
"thumbs_down": null,
"description": "dasdasdasdasd",
"thumbs_up": null,
"created": null
},
{
"name": null,
"created_at": "2011-01-14T00:57:30Z",
"updated_at": "2011-01-14T00:57:30Z",
"store_id": 1,
"id": 6,
"active_date": null,
"thumbs_down": null,
"description": null,
"thumbs_up": null,
"created": null
}
],
"earns": [
{
"name": "JEFF",
"created_at": "2011-01-25T06:18:11Z",
"updated_at": "2011-01-25T06:20:24Z",
"store_id": 1,
"id": 1
}
],
"email": "[email protected]"
}
]
}
I get errors while using TPL to render the data. the WEIRDEST thing about it is that I can get one of the three hasMany to display it's data (which tells me they are configured properly, but cannot get the other 2 to show up.)
And the WEIRDEST thing of all is that if I change up the ordering of my models in the index.html file I can predictably cause errors for the Deals model if it's not included first.
My Xtemplate:
Code:
itemTpl: new Ext.XTemplate(
'<tpl for=".">',
'<h1>{name}{records}</h1>',
'<h2>{network}</h2>',
'<h2>{phone}</h2>',
'<h2>{email}</h2>',
'</tpl>',
'<tpl for="earns">',
'<h1>{name}{records}</h1>',
'<h2>{description}</h2>',
'</tpl>',
'<tpl for="deals">',
'<h1>{name}{records}</h1>',
'<h2>{description}</h2>',
'</tpl>',
'<tpl for="rewards">',
'<h1>{name}{records}</h1>',
'<h2>{description}</h2>',
'</tpl>',