Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP AclNode::node() - Couldn't find Aro node identified
    text
    copied!<p>So i have the following relation:</p> <p><strong>User:</strong></p> <pre><code> &lt;?php App::uses('AppModel', 'Model'); /** * User Model * * @property Roles $Roles */ class User extends AppModel { public $actsAs = array('Acl' =&gt; array('type' =&gt; 'requester')); public $belongsTo = array('Role'); public function parentNode() { if (!$this-&gt;id &amp;&amp; empty($this-&gt;data)) { return null; } if (isset($this-&gt;data['User']['role_id'])) { $roleId = $this-&gt;data['User']['role_id']; } else { $roleId = $this-&gt;field('role_id'); } if (!$roleId) { return null; } else { return array('Role' =&gt; array('id' =&gt; $roleId)); } } /** * Display field * * @var string */ public $displayField = 'username'; public function beforeSave($options = array()) { $this-&gt;data['User']['password'] = AuthComponent::password($this-&gt;data['User']['password']); return true; } //The Associations below have been created with all possible keys, those that are not needed can be removed /** * belongsTo associations * * @var array */ } </code></pre> <p><strong>Role:</strong></p> <pre><code> &lt;?php App::uses('AppModel', 'Model'); class Role extends AppModel { public $actsAs = array('Acl' =&gt; array('type' =&gt; 'requester')); public function parentNode() { return null; } public $displayField = 'name'; } </code></pre> <p>I have setup the Aro and aco tables in my database. Now when ever i try to add a user i get the following error message:</p> <pre><code>AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] =&gt; Role [Aro0.foreign_key] =&gt; 1 ) " </code></pre> <p>I feel like ive tried everything. </p> <p>Does anyone know why this is happening?</p> <p>My save logic (Add action):</p> <pre><code> public function add() { if ($this-&gt;request-&gt;is('post')) { $this-&gt;User-&gt;create(); if ($this-&gt;User-&gt;saveAll($this-&gt;request-&gt;data)) { $this-&gt;Session-&gt;setFlash(__('The user has been saved.')); return $this-&gt;redirect(array('action' =&gt; 'index')); } else { $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.')); } } $roles = $this-&gt;User-&gt;Role-&gt;find('list'); $this-&gt;set(compact('roles')); } </code></pre> <p><strong>Error message and stacktrace:</strong></p> <pre><code> 2013-09-13 14:28:56 Error: [CakeException] AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] =&gt; Role [Aro0.foreign_key] =&gt; 1 ) " Request URL: /udlejnings-priser/cake/users/add Stack Trace: #0 /var/www/udlejnings-priser/cake/lib/Cake/Model/Behavior/AclBehavior.php(92): AclNode-&gt;node(Array) #1 /var/www/udlejnings-priser/cake/lib/Cake/Model/Behavior/AclBehavior.php(110): AclBehavior-&gt;node(Object(User), Array, 'Aro') #2 [internal function]: AclBehavior-&gt;afterSave(Object(User), true, Array) #3 /var/www/udlejnings-priser/cake/lib/Cake/Utility/ObjectCollection.php(132): call_user_func_array(Array, Array) #4 [internal function]: ObjectCollection-&gt;trigger(Object(CakeEvent)) #5 /var/www/udlejnings-priser/cake/lib/Cake/Event/CakeEventManager.php(248): call_user_func(Array, Object(CakeEvent)) #6 /var/www/udlejnings-priser/cake/lib/Cake/Model/Model.php(1789): CakeEventManager-&gt;dispatch(Object(CakeEvent)) #7 /var/www/udlejnings-priser/cake/lib/Cake/Model/Model.php(2270): Model-&gt;save(Array, Array) #8 /var/www/udlejnings-priser/cake/lib/Cake/Model/Model.php(2073): Model-&gt;saveAssociated(Array, Array) #9 /var/www/udlejnings-priser/cake/app/Controller/UsersController.php(82): Model-&gt;saveAll(Array) #10 [internal function]: UsersController-&gt;add() #11 /var/www/udlejnings-priser/cake/lib/Cake/Controller/Controller.php(490): ReflectionMethod-&gt;invokeArgs(Object(UsersController), Array) #12 /var/www/udlejnings-priser/cake/lib/Cake/Routing/Dispatcher.php(187): Controller-&gt;invokeAction(Object(CakeRequest)) #13 /var/www/udlejnings-priser/cake/lib/Cake/Routing/Dispatcher.php(162): Dispatcher-&gt;_invoke(Object(UsersController), Object(CakeRequest), Object(CakeResponse)) #14 /var/www/udlejnings-priser/cake/app/webroot/index.php(110): Dispatcher-&gt;dispatch(Object(CakeRequest), Object(CakeResponse)) #15 {main} </code></pre> <p><strong>My Post request</strong></p> <pre><code> Data = {array}[1] User = {array}[3] username = test2 password = test role_id = 1 </code></pre> <p><strong>Cake version 2.4.0</strong> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload