title: AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User [Aro0.foreign_key] => ) "
body: <p><strong>User.php</strong></p>
  
  <pre><code>App::uses('AuthComponent', 'Controller/Component');
  </code></pre>
  
  <p>class User extends AppModel {</p>
  
  <pre><code>public $primaryKey = 'usu_codigo';
  public $foreignKey = 'usu_gru_codigo';
  public $useTable = 'painel_usuario';
  
  //public $recursive = 0;
  
  
  public function beforeSave($options = array()) {
      $this-&gt;data['User']['usu_senha'] = AuthComponent::password($this-&gt;data['User']['usu_senha']);
      return true;
  }
  
  public $actsAs = array('Acl' =&gt; array(
          'type' =&gt; 'requester',
          'enabled' =&gt; true
  ));
  
  public function parentNode() {
      if (!$this-&gt;id &amp;&amp; empty($this-&gt;data)) {
          return null;
      }
      if (isset($this-&gt;data['User']['usu_gru_codigo'])) {
          $groupId = $this-&gt;data['User']['usu_gru_codigos'];
      } else {
          $groupId = $this-&gt;field('usu_gru_codigo');
      }
      if (!$groupId) {
          return null;
      } else {
          return array('Group' =&gt; array('id' =&gt; $groupId));
      }
  }
  
  public $name = 'User';
  public $validate = array(
      'usu_email' =&gt; array(
          'required' =&gt; array(
              'rule' =&gt; 'notEmpty',
              'required' =&gt; 'create'
          ),
          'unique' =&gt; array(
              'rule' =&gt; 'isUnique',
              'required' =&gt; 'create'
          ),
          'email' =&gt; array('rule' =&gt; 'email')
      ),
      'usu_senha' =&gt; array(
          'required' =&gt; array(
              'rule' =&gt; 'notEmpty',
              'required' =&gt; 'create'
          ),
          'size' =&gt; array(
              'rule' =&gt; array(
                  'minLength',
                  '8'
              ),
              'message' =&gt; 'Minimum 8 characters long'
          )
      )
  );
  public $belongsTo = array(
      'Group' =&gt; array(
          'className' =&gt; 'Group',
          'foreignKey' =&gt; 'usu_gru_codigo'
      )
  );
  </code></pre>
  
  <p>}</p>
  
  <p><strong>UsersController.php</strong></p>
  
  <pre><code>class UsersController extends AppController {
  
  public function beforefilter() {
      parent::beforeFilter();
      $this-&gt;Auth-&gt;userModel = 'User';
      $this-&gt;Auth-&gt;allow('add', 'logout');
  }
  
  public function isAuthorized() {
      return true;
  }
  
  public function bindNode($user) {
      return array(
          'model' =&gt; 'Group',
          'foreign_key' =&gt; $user['User']['usu_gru_codigo']
      );
  }
  
  public function initDB() {
      $group = $this-&gt;User-&gt;Group;
  
      // Allow admins to everything
      $group-&gt;id = 10;
      $this-&gt;Acl-&gt;allow($group, 'controllers');
  
      // allow basic users to log out
      $this-&gt;Acl-&gt;allow($group, 'controllers/users/logout');
  
      // we add an exit to avoid an ugly "missing views" error message
      echo "all done";
      exit;
  }
  
  public function index() {
      $this-&gt;set('users', $this-&gt;User-&gt;find('all'));
  }
  
  public function add() {
      $this-&gt;set('groups', $this-&gt;User-&gt;Group-&gt;find('list', array(
                  'fields' =&gt; array('gru_nome'),
                  'order' =&gt; array('gru_nome')
      )));
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;User-&gt;create();
          if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;Session-&gt;setFlash(__('Usuário adicionado com sucesso!'));
              return $this-&gt;redirect(array('action' =&gt; 'login'));
          }
          $this-&gt;Session-&gt;setFlash(__('Não foi possível adicionar o usuário!'));
      }
  }
  
  public function login() {
      if ($this-&gt;request-&gt;is('post')) {
          $q = $this-&gt;User-&gt;query('SELECT usu_codigo FROM painel_usuario WHERE usu_email = "' . $this-&gt;request-&gt;data['User']['usu_email'] . '" AND usu_senha = "' . AuthComponent::password($this-&gt;request-&gt;data['User']['usu_senha']) . '";');
          $this-&gt;request-&gt;data['User']['usu_codigo'] = $q[0]['painel_usuario']['usu_codigo'];
          if ($this-&gt;Auth-&gt;login($this-&gt;request-&gt;data)) {//o erro que estava dando era por que não estava passado o request-&gt;data com parâmetro
              debug($this-&gt;request-&gt;data);
              $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
          } else {
              $this-&gt;Session-&gt;setFlash(__('Nome de usuário ou senha incorrestos!'));
          }
      }
  }
  
  public function logout() {
      if ($this-&gt;Auth-&gt;logout()) {
          $this-&gt;Session-&gt;setFlash(__("Adeus!"));
          $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Group.php</strong></p>
  
  <pre><code>class Group extends AppModel {
  
  public $primaryKey = 'gru_codigo';
  public $useTable = 'painel_grupo';
  var $virtualFields = array(
      'id' =&gt; 'gru_codigo',
      'name' =&gt; 'gru_nome'
  );
  public $actsAs = array('Acl' =&gt; array('type' =&gt; 'requester'));
  
  public function parentNode() {
      return null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>GroupsController.php</strong></p>
  
  <pre><code>&lt;?php
  class GroupsController extends AppController {
      public function beforefilter() {
          parent::beforeFilter();
          $this -&gt; Auth -&gt; allow();
      }
  
      public function index() {
          $this -&gt; set('groups', $this -&gt; Group -&gt; find('all', array('order' =&gt; array('Group.gru_nome'))));
      }
  
      public function add() {
          if ($this -&gt; request -&gt; is('post')) {
              $this -&gt; Group -&gt; create();
              if ($this -&gt; Group -&gt; save($this -&gt; request -&gt; data)) {
                  $this -&gt; Session -&gt; setFlash(__('Grupo criado com sucesso!'));
                  return $this -&gt; redirect(array('action' =&gt; 'index'));
              }
              $this -&gt; Session -&gt; setFlash(__('Não foi possível criar o grupo!'));
          }
      }
  
  }
  </code></pre>
  
  <p>in StackOverflow already googled and found nothing that could help me.</p>
  
  <p>always got the error: <strong>AclNode :: node () - Could not find Aro node Identified by "Array ([Aro0.model] => User [Aro0.foreign_key] =>)"</strong></p>
  
  <p>believe that somehow the ForeignKey of groups is not being set ... but I can not find where to set it.</p>