{"action":"created","comment":{"url":"https://api.github.com/repos/StephanYu/myflix/pulls/comments/31765771","id":31765771,"diff_hunk":"@@ -1,3 +1,13 @@\n class ApplicationController < ActionController::Base\n   protect_from_forgery\n+\n+  def authenticate_user\n+    redirect_to sign_in_path unless current_user\n+  end\n+\n+  def current_user\n+    User.find(session[:user_id]) if session[:user_id]","path":"app/controllers/application_controller.rb","position":9,"original_position":9,"commit_id":"3ada5bc89bed3ad7f45a009584072300966642c7","original_commit_id":"3ada5bc89bed3ad7f45a009584072300966642c7","user":{"login":"tomtomecek","id":7385469,"avatar_url":"https://avatars.githubusercontent.com/u/7385469?v=3","gravatar_id":"","url":"https://api.github.com/users/tomtomecek","html_url":"https://github.com/tomtomecek","followers_url":"https://api.github.com/users/tomtomecek/followers","following_url":"https://api.github.com/users/tomtomecek/following{/other_user}","gists_url":"https://api.github.com/users/tomtomecek/gists{/gist_id}","starred_url":"https://api.github.com/users/tomtomecek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomtomecek/subscriptions","organizations_url":"https://api.github.com/users/tomtomecek/orgs","repos_url":"https://api.github.com/users/tomtomecek/repos","events_url":"https://api.github.com/users/tomtomecek/events{/privacy}","received_events_url":"https://api.github.com/users/tomtomecek/received_events","type":"User","site_admin":false},"body":"You should cache the result of this method. It is frequently used/called so you want the result to be cached in memory. You can use memoization for that purpose.\r\n\r\n```ruby\r\ndef current_user\r\n  @current_user ||= User.find(session[:user_id]) if session[:user_id]\r\nend\r\n```","created_at":"2015-06-04T21:07:12Z","updated_at":"2015-06-04T21:07:12Z","html_url":"https://github.com/StephanYu/myflix/pull/1#discussion_r31765771","pull_request_url":"https://api.github.com/repos/StephanYu/myflix/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/comments/31765771"},"html":{"href":"https://github.com/StephanYu/myflix/pull/1#discussion_r31765771"},"pull_request":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/StephanYu/myflix/pulls/1","id":36975941,"html_url":"https://github.com/StephanYu/myflix/pull/1","diff_url":"https://github.com/StephanYu/myflix/pull/1.diff","patch_url":"https://github.com/StephanYu/myflix/pull/1.patch","issue_url":"https://api.github.com/repos/StephanYu/myflix/issues/1","number":1,"state":"open","locked":false,"title":"Recent videos feature","user":{"login":"StephanYu","id":7511211,"avatar_url":"https://avatars.githubusercontent.com/u/7511211?v=3","gravatar_id":"","url":"https://api.github.com/users/StephanYu","html_url":"https://github.com/StephanYu","followers_url":"https://api.github.com/users/StephanYu/followers","following_url":"https://api.github.com/users/StephanYu/following{/other_user}","gists_url":"https://api.github.com/users/StephanYu/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanYu/subscriptions","organizations_url":"https://api.github.com/users/StephanYu/orgs","repos_url":"https://api.github.com/users/StephanYu/repos","events_url":"https://api.github.com/users/StephanYu/events{/privacy}","received_events_url":"https://api.github.com/users/StephanYu/received_events","type":"User","site_admin":false},"body":"I created this branch for the recent videos feature but forgot to create a new branch for user authentication. So all of the user authentication features and related pages are now in this branch. \r\n","created_at":"2015-06-04T20:41:57Z","updated_at":"2015-06-04T21:07:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9fa18bea846d50d497cd7f53419fd7b0c8a139f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/StephanYu/myflix/pulls/1/commits","review_comments_url":"https://api.github.com/repos/StephanYu/myflix/pulls/1/comments","review_comment_url":"https://api.github.com/repos/StephanYu/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StephanYu/myflix/issues/1/comments","statuses_url":"https://api.github.com/repos/StephanYu/myflix/statuses/3ada5bc89bed3ad7f45a009584072300966642c7","head":{"label":"StephanYu:recent_videos_feature","ref":"recent_videos_feature","sha":"3ada5bc89bed3ad7f45a009584072300966642c7","user":{"login":"StephanYu","id":7511211,"avatar_url":"https://avatars.githubusercontent.com/u/7511211?v=3","gravatar_id":"","url":"https://api.github.com/users/StephanYu","html_url":"https://github.com/StephanYu","followers_url":"https://api.github.com/users/StephanYu/followers","following_url":"https://api.github.com/users/StephanYu/following{/other_user}","gists_url":"https://api.github.com/users/StephanYu/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanYu/subscriptions","organizations_url":"https://api.github.com/users/StephanYu/orgs","repos_url":"https://api.github.com/users/StephanYu/repos","events_url":"https://api.github.com/users/StephanYu/events{/privacy}","received_events_url":"https://api.github.com/users/StephanYu/received_events","type":"User","site_admin":false},"repo":{"id":33315388,"name":"myflix","full_name":"StephanYu/myflix","owner":{"login":"StephanYu","id":7511211,"avatar_url":"https://avatars.githubusercontent.com/u/7511211?v=3","gravatar_id":"","url":"https://api.github.com/users/StephanYu","html_url":"https://github.com/StephanYu","followers_url":"https://api.github.com/users/StephanYu/followers","following_url":"https://api.github.com/users/StephanYu/following{/other_user}","gists_url":"https://api.github.com/users/StephanYu/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanYu/subscriptions","organizations_url":"https://api.github.com/users/StephanYu/orgs","repos_url":"https://api.github.com/users/StephanYu/repos","events_url":"https://api.github.com/users/StephanYu/events{/privacy}","received_events_url":"https://api.github.com/users/StephanYu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StephanYu/myflix","description":"a clone of the popular videostreaming service Netflix. Focus on TDD. ","fork":false,"url":"https://api.github.com/repos/StephanYu/myflix","forks_url":"https://api.github.com/repos/StephanYu/myflix/forks","keys_url":"https://api.github.com/repos/StephanYu/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StephanYu/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StephanYu/myflix/teams","hooks_url":"https://api.github.com/repos/StephanYu/myflix/hooks","issue_events_url":"https://api.github.com/repos/StephanYu/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/StephanYu/myflix/events","assignees_url":"https://api.github.com/repos/StephanYu/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/StephanYu/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/StephanYu/myflix/tags","blobs_url":"https://api.github.com/repos/StephanYu/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StephanYu/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StephanYu/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/StephanYu/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StephanYu/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/StephanYu/myflix/languages","stargazers_url":"https://api.github.com/repos/StephanYu/myflix/stargazers","contributors_url":"https://api.github.com/repos/StephanYu/myflix/contributors","subscribers_url":"https://api.github.com/repos/StephanYu/myflix/subscribers","subscription_url":"https://api.github.com/repos/StephanYu/myflix/subscription","commits_url":"https://api.github.com/repos/StephanYu/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/StephanYu/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/StephanYu/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/StephanYu/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/StephanYu/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/StephanYu/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StephanYu/myflix/merges","archive_url":"https://api.github.com/repos/StephanYu/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StephanYu/myflix/downloads","issues_url":"https://api.github.com/repos/StephanYu/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/StephanYu/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/StephanYu/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/StephanYu/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StephanYu/myflix/labels{/name}","releases_url":"https://api.github.com/repos/StephanYu/myflix/releases{/id}","created_at":"2015-04-02T15:10:12Z","updated_at":"2015-04-13T15:33:55Z","pushed_at":"2015-06-04T20:41:57Z","git_url":"git://github.com/StephanYu/myflix.git","ssh_url":"git@github.com:StephanYu/myflix.git","clone_url":"https://github.com/StephanYu/myflix.git","svn_url":"https://github.com/StephanYu/myflix","homepage":null,"size":11036,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"StephanYu:master","ref":"master","sha":"f77ecf6c34a71cace33e9027076bd9f49ddca70f","user":{"login":"StephanYu","id":7511211,"avatar_url":"https://avatars.githubusercontent.com/u/7511211?v=3","gravatar_id":"","url":"https://api.github.com/users/StephanYu","html_url":"https://github.com/StephanYu","followers_url":"https://api.github.com/users/StephanYu/followers","following_url":"https://api.github.com/users/StephanYu/following{/other_user}","gists_url":"https://api.github.com/users/StephanYu/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanYu/subscriptions","organizations_url":"https://api.github.com/users/StephanYu/orgs","repos_url":"https://api.github.com/users/StephanYu/repos","events_url":"https://api.github.com/users/StephanYu/events{/privacy}","received_events_url":"https://api.github.com/users/StephanYu/received_events","type":"User","site_admin":false},"repo":{"id":33315388,"name":"myflix","full_name":"StephanYu/myflix","owner":{"login":"StephanYu","id":7511211,"avatar_url":"https://avatars.githubusercontent.com/u/7511211?v=3","gravatar_id":"","url":"https://api.github.com/users/StephanYu","html_url":"https://github.com/StephanYu","followers_url":"https://api.github.com/users/StephanYu/followers","following_url":"https://api.github.com/users/StephanYu/following{/other_user}","gists_url":"https://api.github.com/users/StephanYu/gists{/gist_id}","starred_url":"https://api.github.com/users/StephanYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephanYu/subscriptions","organizations_url":"https://api.github.com/users/StephanYu/orgs","repos_url":"https://api.github.com/users/StephanYu/repos","events_url":"https://api.github.com/users/StephanYu/events{/privacy}","received_events_url":"https://api.github.com/users/StephanYu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StephanYu/myflix","description":"a clone of the popular videostreaming service Netflix. Focus on TDD. ","fork":false,"url":"https://api.github.com/repos/StephanYu/myflix","forks_url":"https://api.github.com/repos/StephanYu/myflix/forks","keys_url":"https://api.github.com/repos/StephanYu/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StephanYu/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StephanYu/myflix/teams","hooks_url":"https://api.github.com/repos/StephanYu/myflix/hooks","issue_events_url":"https://api.github.com/repos/StephanYu/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/StephanYu/myflix/events","assignees_url":"https://api.github.com/repos/StephanYu/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/StephanYu/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/StephanYu/myflix/tags","blobs_url":"https://api.github.com/repos/StephanYu/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StephanYu/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StephanYu/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/StephanYu/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StephanYu/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/StephanYu/myflix/languages","stargazers_url":"https://api.github.com/repos/StephanYu/myflix/stargazers","contributors_url":"https://api.github.com/repos/StephanYu/myflix/contributors","subscribers_url":"https://api.github.com/repos/StephanYu/myflix/subscribers","subscription_url":"https://api.github.com/repos/StephanYu/myflix/subscription","commits_url":"https://api.github.com/repos/StephanYu/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/StephanYu/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/StephanYu/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/StephanYu/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/StephanYu/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/StephanYu/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StephanYu/myflix/merges","archive_url":"https://api.github.com/repos/StephanYu/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StephanYu/myflix/downloads","issues_url":"https://api.github.com/repos/StephanYu/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/StephanYu/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/StephanYu/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/StephanYu/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StephanYu/myflix/labels{/name}","releases_url":"https://api.github.com/repos/StephanYu/myflix/releases{/id}","created_at":"2015-04-02T15:10:12Z","updated_at":"2015-04-13T15:33:55Z","pushed_at":"2015-06-04T20:41:57Z","git_url":"git://github.com/StephanYu/myflix.git","ssh_url":"git@github.com:StephanYu/myflix.git","clone_url":"https://github.com/StephanYu/myflix.git","svn_url":"https://github.com/StephanYu/myflix","homepage":null,"size":11036,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/1"},"html":{"href":"https://github.com/StephanYu/myflix/pull/1"},"issue":{"href":"https://api.github.com/repos/StephanYu/myflix/issues/1"},"comments":{"href":"https://api.github.com/repos/StephanYu/myflix/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StephanYu/myflix/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/StephanYu/myflix/statuses/3ada5bc89bed3ad7f45a009584072300966642c7"}}}}