categories icon indicating copy to clipboard operation
categories copied to clipboard

Cake pluralizes categorized and targets wrong table.

Open pixelmixer opened this issue 15 years ago • 2 comments

Using the example code on a fresh Cake 2.0 install with migrations applied I get the following error.

Error: Database table categorizeds for model Categorized was not found.

It seems to be failing at this step.

public $hasAndBelongsToMany = array(
        'Category' => array(
            'className' => 'Categories.Category',
            'foreignKey' => 'foreign_key',
            'associationForeignKey' => 'category_id',
            'with' => 'Categorized'
        )
    );

The migrations worked fine and I have the categories and categorized tables working fine, so the expected result is that it does not attempt to pluralize the 'with' => 'Categorized' table.

pixelmixer avatar Oct 28 '11 15:10 pixelmixer

This seems to be an issue with new changes in Cake2.0. The problem seems to be with the example code in the readme. If you change the code above to the following, then it at least won't error out on that part when using multiple categories per object.

class Articles extends AppModel {
    public $hasAndBelongsToMany = array(
        'Category' => array(
            'className' => 'Categories.Category',
            'foreignKey' => 'foreign_key',
            'associationForeignKey' => 'category_id',
            'with' => 'Categories.Categorized'
        )
    );
}

pixelmixer avatar Nov 07 '11 22:11 pixelmixer

Thanks for showing this, corrected it!

burzum avatar Nov 11 '11 20:11 burzum