I've created controller QuizController and added action actionEasy(). But then I click to link like http://mysite/quiz/easy I've got 404 error. What I'm doing wrong? Thanks.
1 Answer
If you have created your controller with gii or console, take a look at the accessRules method.
class MyController extends CController
{
......
public function accessRules()
{
return array(
array('deny',
'actions'=>array('create', 'edit'),
'users'=>array('?'),
),
array('allow',
'actions'=>array('delete'),
'roles'=>array('admin'),
),
array('deny',
'actions'=>array('delete'),
'users'=>array('*'),
),
);
}
}
You may want to add the easy action to some allow array, depending on the permissions that it needs.
6 Comments
Marat_Galiev
Thanks, but this doesn't help. Maybe I need to describe routes in some file?
mpj.dev
Can you post your controller code and describe folder structure?
Marat_Galiev
<?php class QuizController extends CController { public function actionEasy() { } public function actionMiddle() { } public function actionHard() { } } ?> My controller. My directory structure is default.
mpj.dev
Have you tried with mysite/index.php/quiz/easy ? If it works, you will have to put a
htaccess file to make some rewrite rules.Marat_Galiev
Sorry, I've put my controller to /quiz/ dir, now I move it to the same level with SiteController, and when I click on a link, I've got a blank page.
|