{"action":"created","comment":{"url":"https://api.github.com/repos/athifw/haxxor/pulls/comments/34614845","id":34614845,"diff_hunk":"@@ -0,0 +1,19 @@\n+class DownvotesController < ApplicationController\n+  before_action :require_login, only: [:create]\n+\n+  def create\n+    @vote = parent.votes.for_user(current_user).first_or_initialize\n+    @vote.score = -1\n+    @vote.save","path":"app/controllers/downvotes_controller.rb","position":7,"original_position":7,"commit_id":"2d1a84c2cc368b7e08ad1707cf3068753747f5ab","original_commit_id":"2d1a84c2cc368b7e08ad1707cf3068753747f5ab","user":{"login":"yaychris","id":13268,"avatar_url":"https://avatars.githubusercontent.com/u/13268?v=3","gravatar_id":"","url":"https://api.github.com/users/yaychris","html_url":"https://github.com/yaychris","followers_url":"https://api.github.com/users/yaychris/followers","following_url":"https://api.github.com/users/yaychris/following{/other_user}","gists_url":"https://api.github.com/users/yaychris/gists{/gist_id}","starred_url":"https://api.github.com/users/yaychris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaychris/subscriptions","organizations_url":"https://api.github.com/users/yaychris/orgs","repos_url":"https://api.github.com/users/yaychris/repos","events_url":"https://api.github.com/users/yaychris/events{/privacy}","received_events_url":"https://api.github.com/users/yaychris/received_events","type":"User","site_admin":false},"body":"Worth noting that `#update_attribute` skips validations. A one-liner that does run validations would be `@vote.update_attributes(score: -1)`","created_at":"2015-07-14T20:25:24Z","updated_at":"2015-07-14T20:25:24Z","html_url":"https://github.com/athifw/haxxor/pull/11#discussion_r34614845","pull_request_url":"https://api.github.com/repos/athifw/haxxor/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/athifw/haxxor/pulls/comments/34614845"},"html":{"href":"https://github.com/athifw/haxxor/pull/11#discussion_r34614845"},"pull_request":{"href":"https://api.github.com/repos/athifw/haxxor/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/athifw/haxxor/pulls/11","id":39950834,"html_url":"https://github.com/athifw/haxxor/pull/11","diff_url":"https://github.com/athifw/haxxor/pull/11.diff","patch_url":"https://github.com/athifw/haxxor/pull/11.patch","issue_url":"https://api.github.com/repos/athifw/haxxor/issues/11","number":11,"state":"open","locked":false,"title":"Added ability to upvote and downvote both articles and comments. ","user":{"login":"athifw","id":7432170,"avatar_url":"https://avatars.githubusercontent.com/u/7432170?v=3","gravatar_id":"","url":"https://api.github.com/users/athifw","html_url":"https://github.com/athifw","followers_url":"https://api.github.com/users/athifw/followers","following_url":"https://api.github.com/users/athifw/following{/other_user}","gists_url":"https://api.github.com/users/athifw/gists{/gist_id}","starred_url":"https://api.github.com/users/athifw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athifw/subscriptions","organizations_url":"https://api.github.com/users/athifw/orgs","repos_url":"https://api.github.com/users/athifw/repos","events_url":"https://api.github.com/users/athifw/events{/privacy}","received_events_url":"https://api.github.com/users/athifw/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-14T19:09:33Z","updated_at":"2015-07-14T20:25:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15b146a1f7aad48b4a281df62c7e3c9e05bfae7c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/athifw/haxxor/pulls/11/commits","review_comments_url":"https://api.github.com/repos/athifw/haxxor/pulls/11/comments","review_comment_url":"https://api.github.com/repos/athifw/haxxor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/athifw/haxxor/issues/11/comments","statuses_url":"https://api.github.com/repos/athifw/haxxor/statuses/2d1a84c2cc368b7e08ad1707cf3068753747f5ab","head":{"label":"athifw:voting","ref":"voting","sha":"2d1a84c2cc368b7e08ad1707cf3068753747f5ab","user":{"login":"athifw","id":7432170,"avatar_url":"https://avatars.githubusercontent.com/u/7432170?v=3","gravatar_id":"","url":"https://api.github.com/users/athifw","html_url":"https://github.com/athifw","followers_url":"https://api.github.com/users/athifw/followers","following_url":"https://api.github.com/users/athifw/following{/other_user}","gists_url":"https://api.github.com/users/athifw/gists{/gist_id}","starred_url":"https://api.github.com/users/athifw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athifw/subscriptions","organizations_url":"https://api.github.com/users/athifw/orgs","repos_url":"https://api.github.com/users/athifw/repos","events_url":"https://api.github.com/users/athifw/events{/privacy}","received_events_url":"https://api.github.com/users/athifw/received_events","type":"User","site_admin":false},"repo":{"id":37745632,"name":"haxxor","full_name":"athifw/haxxor","owner":{"login":"athifw","id":7432170,"avatar_url":"https://avatars.githubusercontent.com/u/7432170?v=3","gravatar_id":"","url":"https://api.github.com/users/athifw","html_url":"https://github.com/athifw","followers_url":"https://api.github.com/users/athifw/followers","following_url":"https://api.github.com/users/athifw/following{/other_user}","gists_url":"https://api.github.com/users/athifw/gists{/gist_id}","starred_url":"https://api.github.com/users/athifw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athifw/subscriptions","organizations_url":"https://api.github.com/users/athifw/orgs","repos_url":"https://api.github.com/users/athifw/repos","events_url":"https://api.github.com/users/athifw/events{/privacy}","received_events_url":"https://api.github.com/users/athifw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/athifw/haxxor","description":"Hacker News Clone","fork":false,"url":"https://api.github.com/repos/athifw/haxxor","forks_url":"https://api.github.com/repos/athifw/haxxor/forks","keys_url":"https://api.github.com/repos/athifw/haxxor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/athifw/haxxor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/athifw/haxxor/teams","hooks_url":"https://api.github.com/repos/athifw/haxxor/hooks","issue_events_url":"https://api.github.com/repos/athifw/haxxor/issues/events{/number}","events_url":"https://api.github.com/repos/athifw/haxxor/events","assignees_url":"https://api.github.com/repos/athifw/haxxor/assignees{/user}","branches_url":"https://api.github.com/repos/athifw/haxxor/branches{/branch}","tags_url":"https://api.github.com/repos/athifw/haxxor/tags","blobs_url":"https://api.github.com/repos/athifw/haxxor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/athifw/haxxor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/athifw/haxxor/git/refs{/sha}","trees_url":"https://api.github.com/repos/athifw/haxxor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/athifw/haxxor/statuses/{sha}","languages_url":"https://api.github.com/repos/athifw/haxxor/languages","stargazers_url":"https://api.github.com/repos/athifw/haxxor/stargazers","contributors_url":"https://api.github.com/repos/athifw/haxxor/contributors","subscribers_url":"https://api.github.com/repos/athifw/haxxor/subscribers","subscription_url":"https://api.github.com/repos/athifw/haxxor/subscription","commits_url":"https://api.github.com/repos/athifw/haxxor/commits{/sha}","git_commits_url":"https://api.github.com/repos/athifw/haxxor/git/commits{/sha}","comments_url":"https://api.github.com/repos/athifw/haxxor/comments{/number}","issue_comment_url":"https://api.github.com/repos/athifw/haxxor/issues/comments{/number}","contents_url":"https://api.github.com/repos/athifw/haxxor/contents/{+path}","compare_url":"https://api.github.com/repos/athifw/haxxor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/athifw/haxxor/merges","archive_url":"https://api.github.com/repos/athifw/haxxor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/athifw/haxxor/downloads","issues_url":"https://api.github.com/repos/athifw/haxxor/issues{/number}","pulls_url":"https://api.github.com/repos/athifw/haxxor/pulls{/number}","milestones_url":"https://api.github.com/repos/athifw/haxxor/milestones{/number}","notifications_url":"https://api.github.com/repos/athifw/haxxor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/athifw/haxxor/labels{/name}","releases_url":"https://api.github.com/repos/athifw/haxxor/releases{/id}","created_at":"2015-06-19T21:00:08Z","updated_at":"2015-06-19T21:05:50Z","pushed_at":"2015-07-14T19:09:33Z","git_url":"git://github.com/athifw/haxxor.git","ssh_url":"git@github.com:athifw/haxxor.git","clone_url":"https://github.com/athifw/haxxor.git","svn_url":"https://github.com/athifw/haxxor","homepage":null,"size":312,"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":"athifw:master","ref":"master","sha":"19023ee8bff55d339004a711b29abb522d56f1fe","user":{"login":"athifw","id":7432170,"avatar_url":"https://avatars.githubusercontent.com/u/7432170?v=3","gravatar_id":"","url":"https://api.github.com/users/athifw","html_url":"https://github.com/athifw","followers_url":"https://api.github.com/users/athifw/followers","following_url":"https://api.github.com/users/athifw/following{/other_user}","gists_url":"https://api.github.com/users/athifw/gists{/gist_id}","starred_url":"https://api.github.com/users/athifw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athifw/subscriptions","organizations_url":"https://api.github.com/users/athifw/orgs","repos_url":"https://api.github.com/users/athifw/repos","events_url":"https://api.github.com/users/athifw/events{/privacy}","received_events_url":"https://api.github.com/users/athifw/received_events","type":"User","site_admin":false},"repo":{"id":37745632,"name":"haxxor","full_name":"athifw/haxxor","owner":{"login":"athifw","id":7432170,"avatar_url":"https://avatars.githubusercontent.com/u/7432170?v=3","gravatar_id":"","url":"https://api.github.com/users/athifw","html_url":"https://github.com/athifw","followers_url":"https://api.github.com/users/athifw/followers","following_url":"https://api.github.com/users/athifw/following{/other_user}","gists_url":"https://api.github.com/users/athifw/gists{/gist_id}","starred_url":"https://api.github.com/users/athifw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/athifw/subscriptions","organizations_url":"https://api.github.com/users/athifw/orgs","repos_url":"https://api.github.com/users/athifw/repos","events_url":"https://api.github.com/users/athifw/events{/privacy}","received_events_url":"https://api.github.com/users/athifw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/athifw/haxxor","description":"Hacker News Clone","fork":false,"url":"https://api.github.com/repos/athifw/haxxor","forks_url":"https://api.github.com/repos/athifw/haxxor/forks","keys_url":"https://api.github.com/repos/athifw/haxxor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/athifw/haxxor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/athifw/haxxor/teams","hooks_url":"https://api.github.com/repos/athifw/haxxor/hooks","issue_events_url":"https://api.github.com/repos/athifw/haxxor/issues/events{/number}","events_url":"https://api.github.com/repos/athifw/haxxor/events","assignees_url":"https://api.github.com/repos/athifw/haxxor/assignees{/user}","branches_url":"https://api.github.com/repos/athifw/haxxor/branches{/branch}","tags_url":"https://api.github.com/repos/athifw/haxxor/tags","blobs_url":"https://api.github.com/repos/athifw/haxxor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/athifw/haxxor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/athifw/haxxor/git/refs{/sha}","trees_url":"https://api.github.com/repos/athifw/haxxor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/athifw/haxxor/statuses/{sha}","languages_url":"https://api.github.com/repos/athifw/haxxor/languages","stargazers_url":"https://api.github.com/repos/athifw/haxxor/stargazers","contributors_url":"https://api.github.com/repos/athifw/haxxor/contributors","subscribers_url":"https://api.github.com/repos/athifw/haxxor/subscribers","subscription_url":"https://api.github.com/repos/athifw/haxxor/subscription","commits_url":"https://api.github.com/repos/athifw/haxxor/commits{/sha}","git_commits_url":"https://api.github.com/repos/athifw/haxxor/git/commits{/sha}","comments_url":"https://api.github.com/repos/athifw/haxxor/comments{/number}","issue_comment_url":"https://api.github.com/repos/athifw/haxxor/issues/comments{/number}","contents_url":"https://api.github.com/repos/athifw/haxxor/contents/{+path}","compare_url":"https://api.github.com/repos/athifw/haxxor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/athifw/haxxor/merges","archive_url":"https://api.github.com/repos/athifw/haxxor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/athifw/haxxor/downloads","issues_url":"https://api.github.com/repos/athifw/haxxor/issues{/number}","pulls_url":"https://api.github.com/repos/athifw/haxxor/pulls{/number}","milestones_url":"https://api.github.com/repos/athifw/haxxor/milestones{/number}","notifications_url":"https://api.github.com/repos/athifw/haxxor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/athifw/haxxor/labels{/name}","releases_url":"https://api.github.com/repos/athifw/haxxor/releases{/id}","created_at":"2015-06-19T21:00:08Z","updated_at":"2015-06-19T21:05:50Z","pushed_at":"2015-07-14T19:09:33Z","git_url":"git://github.com/athifw/haxxor.git","ssh_url":"git@github.com:athifw/haxxor.git","clone_url":"https://github.com/athifw/haxxor.git","svn_url":"https://github.com/athifw/haxxor","homepage":null,"size":312,"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/athifw/haxxor/pulls/11"},"html":{"href":"https://github.com/athifw/haxxor/pull/11"},"issue":{"href":"https://api.github.com/repos/athifw/haxxor/issues/11"},"comments":{"href":"https://api.github.com/repos/athifw/haxxor/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/athifw/haxxor/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/athifw/haxxor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/athifw/haxxor/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/athifw/haxxor/statuses/2d1a84c2cc368b7e08ad1707cf3068753747f5ab"}}}}