Named Scope Throw Cexception Error Message.

Hello everybody! Sorry for the mistakes I’ve made, I from Russia.

I’m new in Yii and learn this one from scratch by reading books and official documentation.

So…recently I tried to use "named scopes", please see that simple code which throw the error:




	public function scopes() {

		return array(

			'testScope' => array(

				'order' => 'date_entered DESC',

				'limit' => 5,

				)

			);

	}


public function actionTest() {

       $model = Page::model()->testScope()->findAll();

       $this->render('test', array('model'=>$model));

}



When I jump to test action, I get the following message:




CException

Page and its behaviors do not have a method or closure named "testScope".



When I rule out testScope() method from the chain(Page::model()->findAll()), everything becomes ok.

By the way, defaultScope() method doesn’t make any affect.

Thanks…

Make sure you’ve created your scope at the right place (models/Page.php in your case)

??? I feel like a fool(

Thank you for quick reply! Now it’s working.

lol it definitely should go to my personal collection :D