public function redirect(ActiveRecord $model = null)
    {
        $route = $this->redirectTo;
        $controller = $this->controller;
        $request = Yii::$app->getRequest();

        // if callable
        if ($model && $route instanceof \Closure) {
            $route = call_user_func($route, $model);
        }

        if ($route === null) {
            return $request->getReferrer() ?
                $controller->redirect($request->getReferrer()) : $controller->goHome();
        }

        return $controller->redirect($route);
    }