You need the alias as cricket said and in your find you need 'contain' => 
array('OpUser', 'User')

El lunes, 8 de octubre de 2012 01:50:05 UTC+2, Greg escribió:
>
> Sure have. Its containable that i'm suspecting is the problem.. Its almost 
> as though it binds the model on the first level of contain, but then fails 
> to rebind it after. If i turn containable off I can query the model with 
> ->find();, but with containable on ->find() throws a non-existant 
> method/non-existant object error.
>
>
> On Mon, Oct 8, 2012 at 2:17 AM, Dave M. <[email protected] <javascript:>>wrote:
>
>> another wild guess: have you attached the Containable behavior?
>>
>> In your AppModel:
>> public $actsAs = array('Containable');
>>
>> -dave
>>
>> On Saturday, October 6, 2012 2:58:54 AM UTC-4, Greg wrote:
>>
>>> Sorry to keep bumping, but this is really doing my head in...
>>>
>>> The only "solution" i have is to load the data without the contained 
>>> users, and then call the users with ajax after the page has loaded - which 
>>> seems a bit daft to me.
>>>
>>> On Tue, Oct 2, 2012 at 10:37 PM, Greg Skerman <[email protected]> wrote:
>>>
>>>>  So even after aliasing everything, the User model appears to become 
>>>> unbound from the OperationParticipant model and doesn't get rebound by 
>>>> containable...
>>>>
>>>> anybody got any clue?
>>>>
>>>>
>>>>
>>>> On Tue, Oct 2, 2012 at 7:54 AM, Greg Skerman <[email protected]> wrote:
>>>>
>>>>> Yeah no dice :( had tried something similar to that before.
>>>>>
>>>>> * Model "OperationParticipant" is not associated with model "OPUser"*
>>>>>
>>>>>
>>>>> On Tue, Oct 2, 2012 at 4:05 AM, lowpass <[email protected]> wrote:
>>>>>
>>>>>> Just a wild guess: in the OperationParticipant model, try changing the
>>>>>> alias for User. Something like:
>>>>>>
>>>>>>     public $belongsTo = array(
>>>>>>         'OPUser' => array(
>>>>>>             'className' => 'User',
>>>>>> ...
>>>>>>
>>>>>> And then change the contain block to have  'OperationParticipant' =>
>>>>>> array('OPUser')
>>>>>>
>>>>>> On Mon, Oct 1, 2012 at 3:05 AM, Greg Skerman <[email protected]> 
>>>>>> wrote:
>>>>>> > I've been wracking my brain over this for a few hours and its doing 
>>>>>> my head
>>>>>> > in.
>>>>>> >
>>>>>> > Consider the following models and associations:
>>>>>> >
>>>>>> > Operation belongsTo User, OperationType and hasMany 
>>>>>> OperationParticipant
>>>>>> > OperationType hasMany Operation
>>>>>> > OperationParticipant belongsTo User, Operation
>>>>>> >
>>>>>> > if I dump out the contents of OperationParticipant in the
>>>>>> > OperationParticipants controller, I get exactly what I would expect 
>>>>>> - a list
>>>>>> > of OperationParticipants and the associated list of Users. 
>>>>>> Obviously User is
>>>>>> > correctly associated with OperationParticipant
>>>>>> >
>>>>>> > The problem comes when I want to call up an Operation and list the 
>>>>>> users who
>>>>>> > are participating.
>>>>>> >
>>>>>> > $this->Operation->find('all', array(
>>>>>> >    'contain' => array(
>>>>>> >       'OperationType', 'User', 'OperationParticipant' => 
>>>>>> array('User')
>>>>>> >       )
>>>>>> >    )
>>>>>> > );
>>>>>> >
>>>>>> > I get
>>>>>> >
>>>>>> > Model "OperationParticipant" is not associated with model "User"
>>>>>> >
>>>>>> > If, from within the context of the Operations controller I do
>>>>>> > pr($this->Operation->**OperationParticipants->find('**all'))); I 
>>>>>> get no
>>>>>> > associated data back for OperationParticipants.
>>>>>> >
>>>>>> > Adding OperationParticipants to the $uses property yields the same 
>>>>>> result,
>>>>>> > no associated data.
>>>>>> >
>>>>>> > I've done deep contains before, and I cannot for the life of me 
>>>>>> understand
>>>>>> > why this is acting up.
>>>>>> >
>>>>>> >
>>>>>> > Here are the associations:
>>>>>> >
>>>>>> >
>>>>>> > OperationParticipant.php
>>>>>> >
>>>>>> > /**
>>>>>> >  * belongsTo associations
>>>>>> >  *
>>>>>> >  * @var array
>>>>>> >  */
>>>>>> >     public $belongsTo = array(
>>>>>> >         'User' => array(
>>>>>> >             'className' => 'User',
>>>>>> >             'foreignKey' => 'user_id',
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => ''
>>>>>> >         ),
>>>>>> >         'Operation' => array(
>>>>>> >             'className' => 'Operation',
>>>>>> >             'foreignKey' => 'operation_id',
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => '',
>>>>>> >                         'counterCache' => true
>>>>>> >         )
>>>>>> >     );
>>>>>> >
>>>>>> >
>>>>>> > Operation.php
>>>>>> >
>>>>>> > /**
>>>>>> >  * belongsTo associations
>>>>>> >  *
>>>>>> >  * @var array
>>>>>> >  */
>>>>>> >     public $belongsTo = array(
>>>>>> >         'OperationType' => array(
>>>>>> >             'className' => 'OperationType',
>>>>>> >             'foreignKey' => 'operation_type_id',
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => ''
>>>>>> >         ),
>>>>>> >         'User' => array(
>>>>>> >             'className' => 'User',
>>>>>> >             'foreignKey' => 'user_id',
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => ''
>>>>>> >         )
>>>>>> >     );
>>>>>> >
>>>>>> > /**
>>>>>> >  * hasMany associations
>>>>>> >  *
>>>>>> >  * @var array
>>>>>> >  */
>>>>>> >     public $hasMany = array(
>>>>>> >         'OperationParticipant' => array(
>>>>>> >             'className' => 'OperationParticipant',
>>>>>> >             'foreignKey' => 'operation_id',
>>>>>> >             'dependent' => false,
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => '',
>>>>>> >             'limit' => '',
>>>>>> >             'offset' => '',
>>>>>> >             'exclusive' => '',
>>>>>> >             'finderQuery' => '',
>>>>>> >             'counterQuery' => ''
>>>>>> >         )
>>>>>> >     );
>>>>>> >
>>>>>> >
>>>>>> > OperationType.php
>>>>>> >
>>>>>> > /**
>>>>>> >  * hasMany associations
>>>>>> >  *
>>>>>> >  * @var array
>>>>>> >  */
>>>>>> >     public $hasMany = array(
>>>>>> >         'Operation' => array(
>>>>>> >             'className' => 'Operation',
>>>>>> >             'foreignKey' => 'operation_type_id',
>>>>>> >             'dependent' => false,
>>>>>> >             'conditions' => '',
>>>>>> >             'fields' => '',
>>>>>> >             'order' => '',
>>>>>> >             'limit' => '',
>>>>>> >             'offset' => '',
>>>>>> >             'exclusive' => '',
>>>>>> >             'finderQuery' => '',
>>>>>> >             'counterQuery' => ''
>>>>>> >         )
>>>>>> >     );
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > The users model does not have the association included, Operations 
>>>>>> is a
>>>>>> > plugin which may not always be there so I've not included the 
>>>>>> hasMany (and
>>>>>> > there is no reason to read the data back the other way, i.e. I have 
>>>>>> no
>>>>>> > requirement to get a list of Users and find their associated 
>>>>>> Operations -
>>>>>> > only Operations, and find their associated users.
>>>>>> >
>>>>>> > Can anyone shed any light?
>>>>>> >
>>>>>> > --
>>>>>> > Like Us on FacekBook 
>>>>>> > https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP>
>>>>>> > Find us on Twitter http://twitter.com/CakePHP
>>>>>> >
>>>>>> > ---
>>>>>> > 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
>>>>>> > cake-php+u...@**googlegroups.com.
>>>>>>
>>>>>> > Visit this group at 
>>>>>> > http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en>
>>>>>> .
>>>>>> >
>>>>>> >
>>>>>>
>>>>>> --
>>>>>> Like Us on FacekBook 
>>>>>> https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP>
>>>>>> Find us on Twitter http://twitter.com/CakePHP
>>>>>>
>>>>>> ---
>>>>>> 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 cake-php+u...@**
>>>>>> googlegroups.com.
>>>>>>
>>>>>> Visit this group at 
>>>>>> http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en>
>>>>>> .
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>  -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to