Yii Framework Forum: IndexAction does not have a method named "render". - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

IndexAction does not have a method named "render". Rate Topic: -----

#1 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 02 April 2009 - 12:56 AM

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...
0

#2 User is offline   qwerty 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 290
  • Joined: 20-November 08

Posted 02 April 2009 - 01:05 AM

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


'import'=>array(
'application.controller.index.*',
),


0

#3 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 02 April 2009 - 01:14 AM

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".

0

#4 User is offline   qwerty 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 290
  • Joined: 20-November 08

Posted 02 April 2009 - 03:00 AM

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));

0

#5 User is offline   bas_vdl 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 215
  • Joined: 01-April 09

Posted 02 April 2009 - 07:19 AM

the second solution wokrs for me!

thanks! maybe a good one for the documentation...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users