Question: I am learning Rails following a udemy tutorial. Everything was good until this [error](http://i.stack.imgur.com/cbw1M.png), I keep rewinding the video and watched it over and over following the exact steps but somehow I always end up with this error. 

Please help me the udemy forum as that course is not active at all so I am frustrated.

[this my view page](http://i.stack.imgur.com/hnvZq.png), this page is really weird with all these rules

Answer: 
Your best bet is to use the `$rootScope`. This, as the name implies, correspond to the root scope of your application and is therefore potentially available (via DI) in any of your controllers. All you need to do is add `$rootScope` as a DI dependency in each of your controllers that requires it:

```
function MyCtrl($scope, $rootScope {
  $rootScope...
}

```

In your templates, the `$rootScope` always available by referencing `$root` in an angular expression.

You would do something like this:

```
<p>{{$root.is_logged_in}}</p>

```
if you want to check whether the user is logged in or not
i think the right approach to your problem is to use resolve property in the route, so the user can't navigate to certain pages if he isn't logged in and once he logged in you can inject the user object to the controller

for example to navigate to home page you must be logged in

```
.when("/home", {
templateUrl: "homeView.html",
controller: "homeController",
resolve: {
    user: function(AuthenticationService){
        return AuthenticationService.getUser();
    }
  }
})

app.controller("homeController", function ($scope, user) {
  $scope.user = user;
});

```

<https://www.sitepoint.com/implementing-authentication-angular-applications/>

and if you just want a global variable you can use $rootScope