{"action":"created","comment":{"url":"https://api.github.com/repos/tuanha/teemo/pulls/comments/46117903","id":46117903,"diff_hunk":"@@ -14,7 +14,15 @@ def show\n \n   # GET /tests/new\n   def new\n-    @test = Test.new\n+    me = current_user\n+    user = User.find(me)\n+    @user_current = user\n+    if user.has_role? :admin\n+      @test = Test.new\n+    else\n+      redirect_to \"/\", :alert => \"Access denied.\"\n+    end\n+\n   end","path":"app/controllers/tests_controller.rb","position":14,"original_position":14,"commit_id":"9a4ba8284d6838b4c5ee66e85a75d1f099ea9dda","original_commit_id":"9a4ba8284d6838b4c5ee66e85a75d1f099ea9dda","user":{"login":"tuanha","id":2282062,"avatar_url":"https://avatars.githubusercontent.com/u/2282062?v=3","gravatar_id":"","url":"https://api.github.com/users/tuanha","html_url":"https://github.com/tuanha","followers_url":"https://api.github.com/users/tuanha/followers","following_url":"https://api.github.com/users/tuanha/following{/other_user}","gists_url":"https://api.github.com/users/tuanha/gists{/gist_id}","starred_url":"https://api.github.com/users/tuanha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuanha/subscriptions","organizations_url":"https://api.github.com/users/tuanha/orgs","repos_url":"https://api.github.com/users/tuanha/repos","events_url":"https://api.github.com/users/tuanha/events{/privacy}","received_events_url":"https://api.github.com/users/tuanha/received_events","type":"User","site_admin":false},"body":"1: viết 1 private function để check admin dung befor_filter\r\n  vd: def check_admin\r\n           redirect_to \"/\", :alert => \"Access denied.\" unless curent_user.admin? \r\n       end\r\n\r\n2: tối ưu hoá lại: \r\nchi can: @test = current_user.tests.new()\r\n","created_at":"2015-11-30T08:36:29Z","updated_at":"2015-11-30T08:36:29Z","html_url":"https://github.com/tuanha/teemo/pull/6#discussion_r46117903","pull_request_url":"https://api.github.com/repos/tuanha/teemo/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/comments/46117903"},"html":{"href":"https://github.com/tuanha/teemo/pull/6#discussion_r46117903"},"pull_request":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/tuanha/teemo/pulls/6","id":52095628,"html_url":"https://github.com/tuanha/teemo/pull/6","diff_url":"https://github.com/tuanha/teemo/pull/6.diff","patch_url":"https://github.com/tuanha/teemo/pull/6.patch","issue_url":"https://api.github.com/repos/tuanha/teemo/issues/6","number":6,"state":"open","locked":false,"title":"Developer","user":{"login":"maichanchinh","id":1913647,"avatar_url":"https://avatars.githubusercontent.com/u/1913647?v=3","gravatar_id":"","url":"https://api.github.com/users/maichanchinh","html_url":"https://github.com/maichanchinh","followers_url":"https://api.github.com/users/maichanchinh/followers","following_url":"https://api.github.com/users/maichanchinh/following{/other_user}","gists_url":"https://api.github.com/users/maichanchinh/gists{/gist_id}","starred_url":"https://api.github.com/users/maichanchinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maichanchinh/subscriptions","organizations_url":"https://api.github.com/users/maichanchinh/orgs","repos_url":"https://api.github.com/users/maichanchinh/repos","events_url":"https://api.github.com/users/maichanchinh/events{/privacy}","received_events_url":"https://api.github.com/users/maichanchinh/received_events","type":"User","site_admin":false},"body":"add CanCan, Devise\r\nadd router flow db","created_at":"2015-11-30T08:22:20Z","updated_at":"2015-11-30T08:36:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"312ed13148de0a44ed241d220b3b45ada2830909","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tuanha/teemo/pulls/6/commits","review_comments_url":"https://api.github.com/repos/tuanha/teemo/pulls/6/comments","review_comment_url":"https://api.github.com/repos/tuanha/teemo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tuanha/teemo/issues/6/comments","statuses_url":"https://api.github.com/repos/tuanha/teemo/statuses/9a4ba8284d6838b4c5ee66e85a75d1f099ea9dda","head":{"label":"maichanchinh:developer","ref":"developer","sha":"9a4ba8284d6838b4c5ee66e85a75d1f099ea9dda","user":{"login":"maichanchinh","id":1913647,"avatar_url":"https://avatars.githubusercontent.com/u/1913647?v=3","gravatar_id":"","url":"https://api.github.com/users/maichanchinh","html_url":"https://github.com/maichanchinh","followers_url":"https://api.github.com/users/maichanchinh/followers","following_url":"https://api.github.com/users/maichanchinh/following{/other_user}","gists_url":"https://api.github.com/users/maichanchinh/gists{/gist_id}","starred_url":"https://api.github.com/users/maichanchinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maichanchinh/subscriptions","organizations_url":"https://api.github.com/users/maichanchinh/orgs","repos_url":"https://api.github.com/users/maichanchinh/repos","events_url":"https://api.github.com/users/maichanchinh/events{/privacy}","received_events_url":"https://api.github.com/users/maichanchinh/received_events","type":"User","site_admin":false},"repo":{"id":46911233,"name":"teemo","full_name":"maichanchinh/teemo","owner":{"login":"maichanchinh","id":1913647,"avatar_url":"https://avatars.githubusercontent.com/u/1913647?v=3","gravatar_id":"","url":"https://api.github.com/users/maichanchinh","html_url":"https://github.com/maichanchinh","followers_url":"https://api.github.com/users/maichanchinh/followers","following_url":"https://api.github.com/users/maichanchinh/following{/other_user}","gists_url":"https://api.github.com/users/maichanchinh/gists{/gist_id}","starred_url":"https://api.github.com/users/maichanchinh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maichanchinh/subscriptions","organizations_url":"https://api.github.com/users/maichanchinh/orgs","repos_url":"https://api.github.com/users/maichanchinh/repos","events_url":"https://api.github.com/users/maichanchinh/events{/privacy}","received_events_url":"https://api.github.com/users/maichanchinh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maichanchinh/teemo","description":"nghich cho vui y ma","fork":true,"url":"https://api.github.com/repos/maichanchinh/teemo","forks_url":"https://api.github.com/repos/maichanchinh/teemo/forks","keys_url":"https://api.github.com/repos/maichanchinh/teemo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maichanchinh/teemo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maichanchinh/teemo/teams","hooks_url":"https://api.github.com/repos/maichanchinh/teemo/hooks","issue_events_url":"https://api.github.com/repos/maichanchinh/teemo/issues/events{/number}","events_url":"https://api.github.com/repos/maichanchinh/teemo/events","assignees_url":"https://api.github.com/repos/maichanchinh/teemo/assignees{/user}","branches_url":"https://api.github.com/repos/maichanchinh/teemo/branches{/branch}","tags_url":"https://api.github.com/repos/maichanchinh/teemo/tags","blobs_url":"https://api.github.com/repos/maichanchinh/teemo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maichanchinh/teemo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maichanchinh/teemo/git/refs{/sha}","trees_url":"https://api.github.com/repos/maichanchinh/teemo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maichanchinh/teemo/statuses/{sha}","languages_url":"https://api.github.com/repos/maichanchinh/teemo/languages","stargazers_url":"https://api.github.com/repos/maichanchinh/teemo/stargazers","contributors_url":"https://api.github.com/repos/maichanchinh/teemo/contributors","subscribers_url":"https://api.github.com/repos/maichanchinh/teemo/subscribers","subscription_url":"https://api.github.com/repos/maichanchinh/teemo/subscription","commits_url":"https://api.github.com/repos/maichanchinh/teemo/commits{/sha}","git_commits_url":"https://api.github.com/repos/maichanchinh/teemo/git/commits{/sha}","comments_url":"https://api.github.com/repos/maichanchinh/teemo/comments{/number}","issue_comment_url":"https://api.github.com/repos/maichanchinh/teemo/issues/comments{/number}","contents_url":"https://api.github.com/repos/maichanchinh/teemo/contents/{+path}","compare_url":"https://api.github.com/repos/maichanchinh/teemo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maichanchinh/teemo/merges","archive_url":"https://api.github.com/repos/maichanchinh/teemo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maichanchinh/teemo/downloads","issues_url":"https://api.github.com/repos/maichanchinh/teemo/issues{/number}","pulls_url":"https://api.github.com/repos/maichanchinh/teemo/pulls{/number}","milestones_url":"https://api.github.com/repos/maichanchinh/teemo/milestones{/number}","notifications_url":"https://api.github.com/repos/maichanchinh/teemo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maichanchinh/teemo/labels{/name}","releases_url":"https://api.github.com/repos/maichanchinh/teemo/releases{/id}","created_at":"2015-11-26T07:37:31Z","updated_at":"2015-11-26T07:27:22Z","pushed_at":"2015-11-30T08:21:30Z","git_url":"git://github.com/maichanchinh/teemo.git","ssh_url":"git@github.com:maichanchinh/teemo.git","clone_url":"https://github.com/maichanchinh/teemo.git","svn_url":"https://github.com/maichanchinh/teemo","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tuanha:master","ref":"master","sha":"81d3c8a8a09476b63ea7e48cd8a740c257d865eb","user":{"login":"tuanha","id":2282062,"avatar_url":"https://avatars.githubusercontent.com/u/2282062?v=3","gravatar_id":"","url":"https://api.github.com/users/tuanha","html_url":"https://github.com/tuanha","followers_url":"https://api.github.com/users/tuanha/followers","following_url":"https://api.github.com/users/tuanha/following{/other_user}","gists_url":"https://api.github.com/users/tuanha/gists{/gist_id}","starred_url":"https://api.github.com/users/tuanha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuanha/subscriptions","organizations_url":"https://api.github.com/users/tuanha/orgs","repos_url":"https://api.github.com/users/tuanha/repos","events_url":"https://api.github.com/users/tuanha/events{/privacy}","received_events_url":"https://api.github.com/users/tuanha/received_events","type":"User","site_admin":false},"repo":{"id":46910460,"name":"teemo","full_name":"tuanha/teemo","owner":{"login":"tuanha","id":2282062,"avatar_url":"https://avatars.githubusercontent.com/u/2282062?v=3","gravatar_id":"","url":"https://api.github.com/users/tuanha","html_url":"https://github.com/tuanha","followers_url":"https://api.github.com/users/tuanha/followers","following_url":"https://api.github.com/users/tuanha/following{/other_user}","gists_url":"https://api.github.com/users/tuanha/gists{/gist_id}","starred_url":"https://api.github.com/users/tuanha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuanha/subscriptions","organizations_url":"https://api.github.com/users/tuanha/orgs","repos_url":"https://api.github.com/users/tuanha/repos","events_url":"https://api.github.com/users/tuanha/events{/privacy}","received_events_url":"https://api.github.com/users/tuanha/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tuanha/teemo","description":"nghich cho vui y ma","fork":false,"url":"https://api.github.com/repos/tuanha/teemo","forks_url":"https://api.github.com/repos/tuanha/teemo/forks","keys_url":"https://api.github.com/repos/tuanha/teemo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tuanha/teemo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tuanha/teemo/teams","hooks_url":"https://api.github.com/repos/tuanha/teemo/hooks","issue_events_url":"https://api.github.com/repos/tuanha/teemo/issues/events{/number}","events_url":"https://api.github.com/repos/tuanha/teemo/events","assignees_url":"https://api.github.com/repos/tuanha/teemo/assignees{/user}","branches_url":"https://api.github.com/repos/tuanha/teemo/branches{/branch}","tags_url":"https://api.github.com/repos/tuanha/teemo/tags","blobs_url":"https://api.github.com/repos/tuanha/teemo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tuanha/teemo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tuanha/teemo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tuanha/teemo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tuanha/teemo/statuses/{sha}","languages_url":"https://api.github.com/repos/tuanha/teemo/languages","stargazers_url":"https://api.github.com/repos/tuanha/teemo/stargazers","contributors_url":"https://api.github.com/repos/tuanha/teemo/contributors","subscribers_url":"https://api.github.com/repos/tuanha/teemo/subscribers","subscription_url":"https://api.github.com/repos/tuanha/teemo/subscription","commits_url":"https://api.github.com/repos/tuanha/teemo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tuanha/teemo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tuanha/teemo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tuanha/teemo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tuanha/teemo/contents/{+path}","compare_url":"https://api.github.com/repos/tuanha/teemo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tuanha/teemo/merges","archive_url":"https://api.github.com/repos/tuanha/teemo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tuanha/teemo/downloads","issues_url":"https://api.github.com/repos/tuanha/teemo/issues{/number}","pulls_url":"https://api.github.com/repos/tuanha/teemo/pulls{/number}","milestones_url":"https://api.github.com/repos/tuanha/teemo/milestones{/number}","notifications_url":"https://api.github.com/repos/tuanha/teemo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tuanha/teemo/labels{/name}","releases_url":"https://api.github.com/repos/tuanha/teemo/releases{/id}","created_at":"2015-11-26T07:20:36Z","updated_at":"2015-11-27T01:21:05Z","pushed_at":"2015-11-30T08:22:21Z","git_url":"git://github.com/tuanha/teemo.git","ssh_url":"git@github.com:tuanha/teemo.git","clone_url":"https://github.com/tuanha/teemo.git","svn_url":"https://github.com/tuanha/teemo","homepage":null,"size":51,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/6"},"html":{"href":"https://github.com/tuanha/teemo/pull/6"},"issue":{"href":"https://api.github.com/repos/tuanha/teemo/issues/6"},"comments":{"href":"https://api.github.com/repos/tuanha/teemo/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tuanha/teemo/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/tuanha/teemo/statuses/9a4ba8284d6838b4c5ee66e85a75d1f099ea9dda"}}}}