Jump to content

CakePHP says my controller doesn't exist, but it actually does


CrimpJiggler

Recommended Posts

I created two tables:

CREATE TABLE `comments` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) default NULL,
`content` text,
`post_id` int(11) default NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) default NULL,
`email` varchar(150) default NULL,
`firstname` varchar(60) default NULL,
`lastname` varchar(60) default NULL,
PRIMARY KEY (`id`)
);

then added a model and controller file for each of them.

<?php
class Comment extends AppModel {
	
	var $name = 'Comment';
	public $BelongsTo = 
	array(
		'Solution' => array('className' => 'Solution'),
		'Visitor' => array('className' => 'Visitor')
	);	
}
?>

then added CommentsFolder:

<?php
class CommentsController extends AppController {
	
	var $name = 'Comments';
	var $scaffold;
	
    public $helpers = array('Html', 'Form', 'Session','Text','FieldDisplay','Js'=>array("Jquery"));
    
}
<?php
class Visitor extends AppModel {

	var $name = 'Visitor';
	var $hasMany = array(
		'Solution' => array('className' => 'Solution'),
		'Comment' => array('className' => 'Comment')
	);	
}

?>

<?
class VisitorsController extends AppController {
	
	var $name = 'Visitors';
	var $scaffold;
    public $helpers = array('Html', 'Form', 'Session','Text','FieldDisplay','Js'=>array("Jquery"));
}
?>

The comments page works fine:

b818e43783a6598a734113c752217002.png

 

but on the visitor page it says it can't find the controller:

118f23e4f1d07e6e10df3f7f05c72bd3.png

 

 

 

 

It makes no sense at all. I checked file permissions and all permissions in the Controller folder are identical. I found another thread about this problem and someone told the OP to add pr(App::path("controllers")); to webroot/index.ctp and the person found the problem that way, but in my case they are identical. I've tried changing the URL to lowercase. I can probably just make a new table and rename it to Visitors but I'd prefer to understand whats gone here incase it happens again.

Edited by CrimpJiggler
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.