The error message says that value 61 are used as array refernce, that means in case of single value, I think $idarray
contains only one value, not array refernce, meaning that try to do it like
if( ref $idarray eq 'ARRAY') {
foreach my $id (@$idarray) { #idarray is an array reference
$c->model('My::DB')->find($id)->delete;
} else{
$c->model('My::DB')->find( $idarray )->delete;
}