0

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 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, but this doesn't help. Maybe I need to describe routes in some file?
Can you post your controller code and describe folder structure?
<?php class QuizController extends CController { public function actionEasy() { } public function actionMiddle() { } public function actionHard() { } } ?> My controller. My directory structure is default.
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.
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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.