{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/224","repository_url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/224/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/224/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/224/events","html_url":"https://github.com/ga-wdi-boston/full-stack-project/issues/224","id":151723028,"number":224,"title":"Why is current_user null in certain contexts?","user":{"login":"soynog","id":14940932,"avatar_url":"https://avatars.githubusercontent.com/u/14940932?v=3","gravatar_id":"","url":"https://api.github.com/users/soynog","html_url":"https://github.com/soynog","followers_url":"https://api.github.com/users/soynog/followers","following_url":"https://api.github.com/users/soynog/following{/other_user}","gists_url":"https://api.github.com/users/soynog/gists{/gist_id}","starred_url":"https://api.github.com/users/soynog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soynog/subscriptions","organizations_url":"https://api.github.com/users/soynog/orgs","repos_url":"https://api.github.com/users/soynog/repos","events_url":"https://api.github.com/users/soynog/events{/privacy}","received_events_url":"https://api.github.com/users/soynog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-28T19:25:27Z","updated_at":"2016-04-28T19:49:23Z","closed_at":null,"body":"I'm trying to ensure that a show action can only display a document owned by the current user. Using the current_user object to test this has worked for the index action. But for some reason when I try it on the show action I get an error because the object is null (and thus doesn't have an id).\r\n\r\nHere is the offending code:\r\n```rb\r\n  def user_documents\r\n    Document.where('user_id = :user', user: current_user.id)\r\n  end\r\n```\r\n\r\nThanks!\r\n"},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/comments/215541877","html_url":"https://github.com/ga-wdi-boston/full-stack-project/issues/224#issuecomment-215541877","issue_url":"https://api.github.com/repos/ga-wdi-boston/full-stack-project/issues/224","id":215541877,"user":{"login":"laurenfazah","id":8062679,"avatar_url":"https://avatars.githubusercontent.com/u/8062679?v=3","gravatar_id":"","url":"https://api.github.com/users/laurenfazah","html_url":"https://github.com/laurenfazah","followers_url":"https://api.github.com/users/laurenfazah/followers","following_url":"https://api.github.com/users/laurenfazah/following{/other_user}","gists_url":"https://api.github.com/users/laurenfazah/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenfazah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenfazah/subscriptions","organizations_url":"https://api.github.com/users/laurenfazah/orgs","repos_url":"https://api.github.com/users/laurenfazah/repos","events_url":"https://api.github.com/users/laurenfazah/events{/privacy}","received_events_url":"https://api.github.com/users/laurenfazah/received_events","type":"User","site_admin":false},"created_at":"2016-04-28T19:49:23Z","updated_at":"2016-04-28T19:49:23Z","body":"If you're using `current_user` in a controller, the controller must inherit from ProtectedController rather than ApplicationController. ProtectedController authorizes the user before any actions whereas ApplicationController skips this. "}}