IndexAction does not have a method named "render".

SEE LAST COMMENT PLS

i try to put each actions in a different file but i get the file not found error.

Filestructure:



private_html


--application


----controller


------index


--------IndexAction.php


------IndexController.php


--framework


public_html


-- index.php


index.php



<?php





// change the following paths if necessary


$yii='/home/bas/projects/yii.dev/private_html/framework/yii.php';


$config='../private_html/application/config/main.php';





// remove the following line when in production mode


defined('YII_DEBUG') or define('YII_DEBUG',true);





require_once($yii);


Yii::createWebApplication($config)->run();


IndexController .php



<?php





class IndexController extends CController


{


	/**


	 * Declares class-based actions.


	 */


	public function actions()


	{


        return array(


            'index' => 'application.controllers.index.IndexAction',


        );


    }


}


Error:



PHP Error


Description





YiiBase::include(IndexAction.php) [<a href='yiibase.include'>yiibase.include</a>]: failed to open stream: No such file or directory


Source File





/home/bas/projects/yii.dev/private_html/framework/YiiBase.php(297)


when i use 'index' => Yii::app()->basePath . '/controllers/index/IndexAction.php' I get Alias "/home/bas/projects/yii.dev/private_html/application/controllers/index/IndexAction.php" is invalid. Make sure it points to an existing directory or file. and when i check the path, the file is there…

Hi,

you have to import your class. You can do this in config file:



'import'=>array(


	'application.controller.index.*',


),





Quote

Hi,

you have to import your class. You can do this in config file:



'import'=>array(


	'application.controller.index.*',


),





application.controllers.index, the s was missing :)

next error

IndexAction.php

Quote

<?php

class IndexAction extends CAction

{

    public function run()

    {

        $sql = "SELECT * FROM users";

        $command = Yii::app()->db->createCommand($sql);

        $rows = $command->queryAll();

        $this->render('index', array('rows' => $rows));

    }

}

Error:



IndexAction does not have a method named "render".


Hi,

in your example was controller ;)

So, I think that you need use getController() (the controller who owns this action).



$this->getController()->render('index', array('rows' => $rows));


or try:



[code]


$this->controller->render('index', array('rows' => $rows));


the second solution wokrs for me!

thanks! maybe a good one for the documentation…