Jump to content

Archived

This topic is now archived and is closed to further replies.

CrimpJiggler

Diagnosing why cake is loading the wrong model

Recommended Posts

I have 6 models connected with HABTM relationships, and on the edit and add pages for each one, I load a list of the other 5. For some reason whenever I try to get a list of "products" it gives me a list of "compounds". There are some glitches with the pagination pages and redirects and stuff and it seems to be the compounds model involved in all these glitches. Changing from $this->model1->Product to ClassRegistry::init('Product') doesn't change anything. Heres one of the HABTM relationships (for the compound model):

	public $hasAndBelongsToMany = array(
		'SubstancesCategory' => array(
			'className' => 'SubstancesCategory',
			'joinTable' => 'substances_cat_rels',
			'foreignKey' => 'compound_id',
			'associationForeignKey' => 'substances_category_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
		),
		'Plant' => array(
			'className' => 'Plant',
			'joinTable' => 'substances_inter_rels',
			'foreignKey' => 'compound_id',
			'associationForeignKey' => 'plant_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
		),
		'Preparation' => array(
			'className' => 'Preparation',
			'joinTable' => 'substances_inter_rels',
			'foreignKey' => 'compound_id',
			'associationForeignKey' => 'preparation_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
		),
		'Product' => array(
			'className' => 'Compound',
			'joinTable' => 'substances_inter_rels',
			'foreignKey' => 'compound_id',
			'associationForeignKey' => 'product_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
		),
		'Ailment' => array(
			'className' => 'Ailment',
			'joinTable' => 'substances_inter_rels',
			'foreignKey' => 'compound_id',
			'associationForeignKey' => 'ailment_id',
			'unique' => 'keepExisting',
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
		)
	);

and heres the problem:

084a7a8a7085aeddd1649ec6c3aa5344.png

I'm using the same controller for 5 of these models, and a seperate controller for categories. I can load the products page fine, its just when I try to load a list that it loads a list of compounds instead. is there anything you can recommend I try to diagnose or fix the issue?

Share this post


Link to post
Share on other sites

×
×
  • 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.