Hello everyone! I’ve learning Yii for a couple of months. I try to make my code more reusable, so i try to build module-based apps. And the first problem which i got is how to use model from one module in another module? For example, i have some relations between two modules (i.e. Users and Posts). As you can guess, my Users model stored in protected/modules/Users/models/Users.php and Posts model - in protected/modules/Posts/models/Posts.php. So then i try to define some relation between these models, i’ve got error. Yii cant find model. For example, my relation for Posts model:
return array( 'author' => array(self::HAS_ONE,'Users','authorid'), )
I think, Yii try to search in default models dir (protected/models). I found one dirty way to fix this issue - by adding full path for import in config/main.php (something like ‘import’ => array(‘application.modules.Users.models.*’). It works fine, but its not a good idea for me. Maybe somebody knows another, smarter way to work between models from different modules?
p.s. sry for my poor english