Hello,
thank's for the reply...
I have added "with" parameter and now all is ok in the new cake
version too.
I have read again the documentation (http://book.cakephp.org/view/78/
Associations-Linking-Models-Together ) and I have observed the use of
"with":

" with: Defines the name of the model for the join table. By default
CakePHP will auto-create a model for you. Using the example above it
would be called RecipesTag. By using this key you can override this
default name. The join table model can be used just like any "regular"
model to access the join table directly."

This is the same thing that You have said.

Thank's again,
(sorry for my bad english!)
Mattia

On 5 Mar, 18:11, Martin Westin <[email protected]> wrote:
> ( 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, "[email protected]"
>
> <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to