why cake PHP framework not recognize true syntax in this example
-
User has Many Photos
-
Photos belongs to User
In User Model
var $hasMany = array( 'Photo' => array( 'className' => 'Photo', 'foreignKey' => 'user_id' );
In Photo Model
var $belongsTo = array( 'user' => array( 'className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '' ), 'PhotoAlbum' => array( 'className' => 'PhotoAlbum', 'foreignKey' => 'photo_album_id', 'conditions' => '', 'fields' => '', 'order' => '', ))
in Photo controller , in add action cake generate this code :
$this->Photo->User->find('all');
but true code is :
$this->Photo->user->find('all');
means user property should upper case but cake not recognize and bake false code.
Also – the problem isn’t cake. The problem is you have a var $name = “user”; in your user model.
Name your model with the cake conventions correctly and this won’t happen. When you don’t follow conventions you run into problems with the framework. The correct solution is to read the manual instead of posting questions with near worthless debug info here @ SO.