I have an one to many association in which a Thing can have many Statuses defined as below:
Status Model:
class Status extends AppModel
{
var $name = 'Status';
var $belongsTo = array(
'Thing' => array(
'className' => 'Thing',
'foreignKey' => 'thing_id',
);
}
Thing Model:
class Thing extends AppModel
{
var $name = 'Thing';
var $belongsTo = array(
// other associations
);
var $hasMany = array(
'Status' => array(
'className' => 'Status',
'foreignKey' => 'thing_id',
'dependent' => false,
'order' => 'datetime DESC',
'limit' => '10',
),
// other associations
);
}
This works OK, but I would like Thing to use a different id to connect to Status. E.g. Thing would use 'id' for all of it's other associations but use 'thing_status_id' for it's Status association.
How can I best do this?