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: 
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
Another approach, yet using the $rootScope, is to use **$broadcast** to create an observer for that variable. 

In order to do this, you should broadcast an event when this variable is changed, like this:

```
$rootScope.$broadcast('user_logged_in');

```

And then, watch it using the $on method. Here:

```
$scope.$on('user_logged_in', function(event, args) {
    // here you do what you want, like:
    $scope.logged_in = true;
});

```

If you want to know more about it, angular also provides the $emmit method, that is used when you want that scopes above yours listen to that event. ( you can find more here : [$rootScope.$broadcast vs. $scope.$emit](https://stackoverflow.com/questions/26752030/rootscope-broadcast-vs-scope-emit)

Yet, you should read more about in the **docs**, [What are scopes?](https://docs.angularjs.org/guide/scope) and here: [$rootScope.Scope](https://docs.angularjs.org/api/ng/type/$rootScope.Scope)