I have tree model with this structures and tables:
Rate:
id, model_name, object_id
1 , SocialPost, 12
public $belongsTo => array(
'SocialPost' => array(
'className' => 'Social.SocialPost',
'foreignKey' => 'object_id',
'conditions' => array(
'Rate.object_id = SocialPost.id',
),
)
)
SocialPost: id, file_id
public $hasOne = array(
'File' => array(
'className' => 'File',
'foreignKey' => false,
'conditions' => array(
'File.id = SocialPost.file_id',
),
),
);
File: id, title
all tree models actsAs containable
this code work nice in SocialPostsController:
$posts = $this->SocialPost->find('all', array(
'limit' => 5,
'contain' => array(
'File'
)
));
output: http://pastie.org/private/9ixxufncwlr3tofgp8ozw
but this code in RatesController return same file for all SocialPost:
$mostRated = $this->Rate->find('all', array(
'limit' => $count,
'contain' => array(
'SocialPost' => array(
'File'
)
)
));
output: http://pastie.org/private/lbqryo1gxgvxjb5omfwrw
what is wrong here?