views:

18

answers:

2

I have a relationship as follows.

  1. Game -> hasMany Highscores
  2. Highscore -> belongsTo Games, Users

When I run the MVC files standalone (within their respective places in the app dir), I get all belongsTo data associated with Highscores. However, when I run the same MVC files as a plugin, within the plugin dir, these associations are lost.

It seems to me that everythig is in order, but to no avail. I am fairly new to cakePHP so I'm sure it's something stupid. I can't for the life figure it out however.

Any help would be greatly appreciated.

I have referenced:

book.cakephp.org/view/117/Plugin-Models trac.cakephp.org/ticket/3876 aranworld.com/article/143/cakephp-model-associations-from-within-plugin-directories

A: 

I ended up using the bindModel method.

$this->Highscore->bindModel(
    array('belongsTo' => array(
            'User' => array(
                'className' => 'SparkPlug.User'
            )
        )
    )
);

Not ideal and still unsure why my relationships/associations are getting lost. But this will have to do.

Keven Ages
A: 

Are you setting up your relationships using the PluginName as the prefix in the joined Model's name?

That sounds awkward - example

<?php
    class MyModel extends AppModel
    {
        public $name = "MyModel";
        public $belongsTo = array(
            'User' => array(
                'className' => 'SparkPlug.User',
            ),
        );
?>
Abba Bryant