user710502
user710502

Reputation: 11471

not recognizing my view

I am new to Cake PHP and this set up is giving me a problem.. i am following the conventions unless you may point me in the right direction (something i may hava missed)

I have this controller

dish_categories_controller.php

<?php
class DishCategoriesController extends AppController {

    var $name = 'Dish_Categories';

    var $uses = array("DishCategory");

    function get_categories($id)
    {
       $this->set('dish_categories',$this->DishCategory->find('first', array('conditions' => array('DishCategory.category_id' == $id))));
       $this->layout = 'master_layout';
    }   
  }
?>

THE MODEL

dish_category.php

<?php
class DishCategory extends AppModel{

    var $name = 'DishCategory';
 }
?>

VIEW

foder:  dish_categories
file:  get_categories.ctp
<?php
print_r($dish_categories);
?>

But i get the following error with this url

myweb/app/dish_categories/get_categories/1


Error: The view for Dish_CategoriesController::get_categories() was not found.

Error: Confirm you have created the file: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\myweb\app\views\dish__categories\get_categories.ctp

I would appreciate your help on this matter

Thank you

Upvotes: 0

Views: 36

Answers (1)

kcsoft
kcsoft

Reputation: 2947

The error is obvious:

Confirm you have created the file: C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\myweb\app\views\dish__categories\get_categories.ctp

Your view must have the same name as the action name. i.e. get_categories.ctp, not dish_categories.ctp like it is now.

edit:

htdocs\myweb\app\views\dish__categories\

has 2 underscores in dish__categories

try to remove this line:

var $name = 'Dish_Categories';

Upvotes: 1

Related Questions