2

Hi I'm trying to use the CakePHP comments plugin found here it gives me the following error

Missing Method in CommentsController Error: The action index is not defined in controller CommentsController Error: Create CommentsController::index() in file: app\controllers\comments_controller.php.

So far I've created the comments table, added it to the plugins and added the following code to Test controller as I want to add comments in 'take' action:

public function beforeFilter() {

parent::beforeFilter(); $this->passedArgs['comment_view_type'] = 'flat'; $this->passedArgs['actionNames'] = 'take'; 

}

function take($id) {

$this->Test->recursive = 2; $this->set('test', $this->Test->read(null, $id)); 

}

I added the route

Router::connect('/comments/:action/*',array('plugin' => 'comments','controller' => 'comments'));

I'm just wondering if anyone has used this plugin before and can help me out?

thanks,

Brary

1
  • It seems that there is a problem with the plugin, so I moved to CakeDC comments plugin github.com/CakeDC/comments Commented Jul 10, 2011 at 0:04

2 Answers 2

1

I haven't used that plugin, but the error is very common in Cake:

Cake is looking for the index function as that is the default or home function for that or any controller. In essence cake is failing because it is try to route to you a page (I am assuming /comments) through the function called index() inside the comments controller. It is core Cake MVC routing functionality.

If you want that page to work, you need to add:

function index(){ ...controller code... } 

to comments_controller.php. However, you will also need to add a index.ctp file to /app/views/comments otherwise cake will give you the missing view error.

What happens at the url /comments/take ?

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

3 Comments

It is a plugin, so I don't have a controller for it, thats why I added the route ..
i am just following the instructions :D
My bad, My guess is that it is routing to the wrong controller, hence the missing action error is being thrown. The error is common enough, but in your situation cake is probably somehow trying to serve the wrong view.
0

Whoa my bad, I didn't see you're not using the official CakeDC comments plugin, which I'd recommend using over the 2009 one you are.

3 Comments

Thanks for reply, I meant I want comments to showup in the 'take' action, thats what I added in the view "<?php echo $this->requestAction('/comments/index/tests/'.$test['Test']['id'], array('return')); ?>"
I just noticed we are talking about different comment plugins, I would use the one I suggested as it's by CakeDC, and is kept updated.
I think the one I am using is built on CakeDC's plugin, adding some features .. thanks for your advice I will try the original plugin .. hope it works ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.