permissionable
permissionable copied to clipboard
$this->Model->find('list'); fails on models with permissionable attached
When trying to do a $this->Model->find('list'); on a model that has the permissionable beavior attached it fails with the following SQL error: (this is for a model called Location
Warning (512): SQL Error: 1051: Unknown table 'LocationPermissionBit' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Query: SELECT `Location`.`id`, `Location`.`name`, `LocationPermissionBit`.* FROM `locations` AS `Location` WHERE 1 = 1
And you can fix it by adding 'recursive' => 0 to your $params array.
strange. i'll see if i can track down what is causing it.
I'm getting the same thing. I set the params variable to array('permissionable'=>false) to get it to work properly.
I'm getting the same issue on mysql,
SELECT
Store.*,
StorePermissionBit.* FROM
storesAS
StoreWHERE 1 = 1 ORDER BY
number asc LIMIT 20
1051: Unknown table 'StorePermissionBit'
Any workaround that doesn't disable the permissionable behavior like above?
Thanks
Hi guys, as a workaround you can put the following in your app model, credit to @darxmac for tracking down recursive=>0 being the problem:
switch ($type) {
case 'list':
$options['recursive'] = 0;
return parent::find('list', $options);
break;
default:
return parent::find($type, $options);
break;
}
}