views:

58

answers:

2

Hello everyone,

I got a problem with cake's model architecture.

I got a Users-Model and a Metas-Model. Here are the model codes:

Users:

<?php
class User extends AppModel {

var $name = 'User';
var $validate = array(
    'username' => array('notempty'),
    'email' => array('email'),
    'password' => array('notempty')
);
    var $displayField = 'username';


var $hasMany = array(
        'Meta' => array(
            'className' => 'Meta',
            'foreignKey' => 'user_id'        
        )
);

}
?>

and the Metas Model:

<?php
class Meta extends AppModel {

var $name = 'Meta';

//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
    'User' => array(
        'className' => 'User',
        'foreignKey' => 'user_id',
        'required' => true
    )
);

}
?>

So now the question is why do I not get the Meta data into the User array? Should I get it in the Auth object?

Or where can I work with the meta data?

hope you can help me!

Have a nice Day! Dom

A: 

Your models seem to be fine.The problem must be in your controller file.See Retrieving data and hasMany relation in the cookbook.

SpawnCxy
A: 

Have you tried:

$currentUserData = $this->User->read(null,$this->Auth->user('id'));
Leo