( I'll skip the usual suggestion: to not use requestAction for this
purpose. It has been said too often and I am sure you have read a few
already. )

That does sound strange. I can suggest only one far-fetched things to
look into.

The very unlikely thing that can mess with the models in this way is
if the same models (or more specifically: other models named the same)
have been loaded into the ClassRegistry before you do the request.
This IS very rare and has only happened to me once. Using
requestAction can probably increase the odds though.

In that case the "other model" was simply Cake creating an "empty"
joining model (based off AppModel) for an association. That model was
then reused when I was trying to load up the "real" joining model. You
can check if the models are there and really descendants of your
models and not direct descendants of AppModel.

Looking at your model definitions I see no "with" parameter specified.
So if the model "Tab" is loaded, it will load an empty "RolesTab" and
nothing you do from that oint on will even get the real RolesTab model
up and running. You will simply re-use the empty one.

Try adding:
'with'  => 'RolesTab',
to both sides of the habtm.


/Martin



On Mar 5, 12:11 pm, "mazzon.mat...@gmail.com"
<mazzon.mat...@gmail.com> wrote:
> Hello,
> I have a problem with requestAction when I change cakephp version from
> 1.2.0.7692 to 1.2.1.8004.
> I have this relations into Models that make a hasAndBelongsToMany from
> Roles table and Tabs table (in the join table I have 2 fileds more:
> position and active) :
>
> class RolesTab extends AppModel {
>
>         var $name = 'RolesTab';
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>         var $belongsTo = array(
>                         'Role' => array('className' => 'Role',
>                                                                 'foreignKey' 
> => 'role_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => ''
>                         ),
>                         'Tab' => array('className' => 'Tab',
>                                                                 'foreignKey' 
> => 'tab_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => ''
>                         )
>         );
>
> }
>
> class Role extends AppModel {
>
>         var $name = 'Role';
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>
>         var $hasAndBelongsToMany = array(
>                         'Tab' => array('className' => 'Tab',
>                                                 'joinTable' => 'roles_tabs',
>                                                 'foreignKey' => 'role_id',
>                                                 'associationForeignKey' => 
> 'tab_id',
>                                                 'unique' => true,
>                                                 'conditions' => '',
>                                                 'fields' => '',
>                                                 'order' => '',
>                                                 'limit' => '',
>                                                 'offset' => '',
>                                                 'finderQuery' => '',
>                                                 'deleteQuery' => '',
>                                                 'insertQuery' => ''
>                         )
>         );
>
> }
>
> class Tab extends AppModel {
>
>         var $name = 'Tab';
>
>         var $hasAndBelongsToMany = array(
>                         'Role' => array('className' => 'Role',
>                                                 'joinTable' => 'roles_tabs',
>                                                 'foreignKey' => 'tab_id',
>                                                 'associationForeignKey' => 
> 'role_id',
>                                                 'unique' => true,
>                                                 'conditions' => '',
>                                                 'fields' => '',
>                                                 'order' => '',
>                                                 'limit' => '',
>                                                 'offset' => '',
>                                                 'finderQuery' => '',
>                                                 'deleteQuery' => '',
>                                                 'insertQuery' => ''
>                         )
>         );
>         var $displayField = 'text';
>
> }
>
> In the roles_tabs_controller I have this method:
>
> function gettabs() {
>
> $dati = $this->RolesTab->find('all', array('conditions'=>array
> ('Role.id'=>1),'order' => 'position ASC' ) ) ;
> ecc...
>
> }
>
> This is the only one method that I have found to retrive all the data:
> tab, Role and rolesTab with order in rolesTab.
> If I run gettabs action directly all is ok, but if I run this action
> with requestAction into another controller (for example post
> controller: $tabs = $this->requestAction(array
> ('controller'=>'roles_tabs','action'=>'gettabs')); )  the action runs
> wihout the associated model (into the final array I don't have the tab
> and role data).
>
> If I work with 1.2.0.7692 cake version all is ok and the requestaction
> return same result when I call gettabs directly.
>
> What' the problem? Is a bug?
>
> Thank's Mattia
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to