Invalid CakePHP Model Name

I'm trying to use CakePHP right now, and I can't get my application to work because CakePHP "thinks" that my model name is "Tach" when it is actually "Tache".

Why is that?

My controller is defined as: application / controllers / taches_controller.php

class TachesController extends AppController { function index() { $allTaches = $this->Tache->find('all'); $this->set('taches', $allTaches); } 

}

And here is my model: application / models / tache.php

 class Tache extends AppModel { var $useTable = 'taches'; 

}

I get an error if I use "Tache" in my controller:

  $allTaches = $this->Tache->find('all'); 

But if I use "Tach", I get no error:

  $allTaches = $this->Tach->find('all'); 

Why can't I use the model name "Tache"? Am I doing something wrong? By the way, I am on php 5.3, and my version of CakePHP is 1.3.8.

Thanks!

Alex

+7
source share
1 answer

CakePHP's default flex rules consider Taches to be a plural form of Tach.

You will need to use the Inflector class to add a custom inflection.

See the following:

To conclude, you need to add the following to the app / config / bootstrap.php file:

 Inflector::rules('plural', array('irregular' => array('tache' => 'taches'))); 
+11
source

All Articles