CakePHP Error: The requested address '/unsigned_images/index' was not found on this server
I'm a beginner CakePHP developer. I'm encountering an Error: The requested address '/unsigned_images/index' was not found on this server.
I'm using the following codes:
Model: app/models/unsigned_image.php
<?php
class UnsignedImage extends AppModel{
var $name = 'UnsignedImage';
var $useDbConfig = 'tabletApp';
var $useTable = 'unsigned_images';
//var $useTable 开发者_如何学JAVA= false;
}
?>
Controller: app/controllers/unsigned_images_controller.php
<?php
class UnsignedImagesController extends AppController{
var $name = 'UnsignedImages';
var $pageTitle = 'Hello world!';
var $helpers = array('Javascript');
var $components = array('Auth', 'Slogic');
function index(){
$this->layout = 'default';
$this->set('data','Hello World!');
$this->set('unsigned_images', $this->UnsignedImage->find('all') );
}
}
?>
View: app/views/unsigned_images/index.ctp
<div style='font-weight: bold; margin: 0 0 10px 0;'>View All Signatures</div>
<table>
<tr>
<th>ID</th>
<th>Session ID</th>
</tr>
<?php
foreach( $unsigned_images as $unsigned_image ){
echo "<tr>";
echo "<td>{$unsigned_image['UnsignedImage']['id']}</td>";
echo "<td>{$unsigned_image['UnsignedImage']['session_id']}</td>";
echo "</tr>";
}
?>
</table>
- I have unsigned_images table in my database
- When I access http://somedomain.com/unsigned_images/index/, it prints the error.
- When I just use var $useTable = false; in the model, no errors were printed.
Many thanks for any help! :)
Two blog posts (here and here) suggest the following steps:
- Ensure your database is configured properly (the table exists, you have access, etc.)
- Make sure the
/tmp
directory is writable - Clear the cache files in the
/tmp
subfolders
Since the errors disappear when you set $useTable
to false
, I would pay particular attention to the first step. Make sure you have the corresponding tabletApp
database configuration in your /app/config/database.php
file.
Also, more helpful troubleshooting information may be available by setting the following line in your core.php
configuration file:
Configure::write('debug', 2);
精彩评论