I have imported the data of users from the CSV file. Now when I try to update user then it is giving me following error
AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User [Aro0.foreign_key] => 292 ) "
The reason is I have imported the data from the CSV file in user but my AROS is not updated.
I have updated the ACO with the following command line "cake AclExtras.AclExtras aco_sync"
.
Can anyone tell how to update my AROS table with new user id generated from CSV import.
Thanks.
There are two ways to update your AROs:
Attach the AclBehavior to the User model and write a method that will save the CSV data using the User model's save method.
// In User Model:
public $actsAs = array(
'Acl' => array(
'type' => 'requester'
);
// In your importCSV() method assuming in your UsersController:
$this->User->saveMany($users);
If you have directly imported user data into your DB not using the Model::save() mehthod, use the acl shell via command line to enter AROs.
cake acl create aro parent_ARO User.user_id
To understand the above syntax, just type cake acl create
.
You would have to run the above command with all the user_ids that you have added.
Update:
Create a file: app/Console/Command/AclGenShell.php.
class AclGenShell extends AppShell {
public $uses = array('User', 'Aro');
public function main() {
$users = $this->User->find('all');
foreach ($users as $user) {
$this->Aro->create();
$this->Aro->save(array(
'model' => 'User',
'foreign_key' => $user['User']['id'],
'parent' => 'parent_ARO_alias'
));
}
}
}
Then run:
cake acl_gen