Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails AngularJS设计授权_Ruby On Rails_Angularjs_Devise - Fatal编程技术网

Ruby on rails AngularJS设计授权

Ruby on rails AngularJS设计授权,ruby-on-rails,angularjs,devise,Ruby On Rails,Angularjs,Devise,我正在尝试向我的应用程序添加授权功能,例如,当我想转到/admin/posts/create时,如果我还没有登录,它会将我重定向到/login 我的角度模块 angular.module('flapperNews', ['ui.router', 'templates', 'ngResource', 'formly', 'formlyBootstrap', 'ngMessages', 'Devise']) 我正在使用这项服务 angular.module('flapperNews') .工厂(“

我正在尝试向我的应用程序添加授权功能,例如,当我想转到/admin/posts/create时,如果我还没有登录,它会将我重定向到/login

我的角度模块

angular.module('flapperNews', ['ui.router', 'templates', 'ngResource', 'formly', 'formlyBootstrap', 'ngMessages', 'Devise'])
我正在使用这项服务 angular.module('flapperNews') .工厂(“授权”[ “$state”, “Auth”, “$location”, 函数($state,Auth,$location){

]))

这些是我的路线

 $stateProvider.state('home', {
        url: '/',
        controller: 'PostsCtrl',
        templateUrl: 'posts/_posts.html'
    });

    $stateProvider.state('admin', {
        abstract: true,
        resolve: {
            authorize: ['authorization', function(authorization) {
                return authorization.authorize();
            }]
        },
        template: '<div ui-view />'
    });

    $stateProvider.state('postsCreate', {
        parent: 'admin',
        url: '/admin/posts/create',
        controller: 'PostsCtrl as vm',
        templateUrl: 'posts/create.html'
    });
$stateProvider.state('home'){
url:“/”,
控制器:“PostsCtrl”,
templateUrl:'posts/_posts.html'
});
$stateProvider.state('admin'{
摘要:没错,
决心:{
授权:[“授权”,功能(授权){
返回authorization.authorization();
}]
},
模板:“”
});
$stateProvider.state('postsCreate'{
家长:'管理员',
url:“/admin/posts/create”,
控制器:“PostsCtrl作为vm”,
templateUrl:'posts/create.html'
});
通过此链接,我试图访问我无法到达的路线

<a ui-sref="postsCreate" class="btn btn-primary">Create a post</a>
创建帖子
我没有得到任何错误,我最终进入了我应该能够访问的部分

<a ui-sref="postsCreate" class="btn btn-primary">Create a post</a>