{"action":"created","comment":{"url":"https://api.github.com/repos/paderinandrey/qna/pulls/comments/77613265","id":77613265,"diff_hunk":"@@ -0,0 +1,43 @@\n+module Votable\n+  extend ActiveSupport::Concern\n+  \n+  included do\n+    has_many :votes, as: :votable, dependent: :destroy\n+  end\n+  \n+  # Returns total user votes\n+  def total\n+    votes.sum(:value)\n+  end\n+  \n+  # Sets user's vote (like or dislike)\n+  def set_evaluate(user, value)\n+    votes.create(user: user, value: value)    \n+  end\n+  \n+  # Changes user's vote\n+  def change_evaluate(user)\n+    votes.where(user: user).update_all(\"value = (-1) * value\")\n+    votes.reload\n+  end  \n+  \n+  # Cancel user's vote\n+  def cancel_evaluate(user)\n+    votes.where(user: user).delete_all\n+  end\n+  \n+  # Return true if user voted\n+  def user_voted?(user)","path":"app/models/concerns/votable.rb","position":30,"original_position":30,"commit_id":"c31d3d1c977e584293d3c9e2535f12c199b90a65","original_commit_id":"c31d3d1c977e584293d3c9e2535f12c199b90a65","user":{"login":"vkurennov","id":968537,"avatar_url":"https://avatars.githubusercontent.com/u/968537?v=3","gravatar_id":"","url":"https://api.github.com/users/vkurennov","html_url":"https://github.com/vkurennov","followers_url":"https://api.github.com/users/vkurennov/followers","following_url":"https://api.github.com/users/vkurennov/following{/other_user}","gists_url":"https://api.github.com/users/vkurennov/gists{/gist_id}","starred_url":"https://api.github.com/users/vkurennov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkurennov/subscriptions","organizations_url":"https://api.github.com/users/vkurennov/orgs","repos_url":"https://api.github.com/users/vkurennov/repos","events_url":"https://api.github.com/users/vkurennov/events{/privacy}","received_events_url":"https://api.github.com/users/vkurennov/received_events","type":"User","site_admin":false},"body":"Этот метод лучше перенести в модель User","created_at":"2016-09-06T10:55:56Z","updated_at":"2016-09-06T10:55:56Z","html_url":"https://github.com/paderinandrey/qna/pull/7#discussion_r77613265","pull_request_url":"https://api.github.com/repos/paderinandrey/qna/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/paderinandrey/qna/pulls/comments/77613265"},"html":{"href":"https://github.com/paderinandrey/qna/pull/7#discussion_r77613265"},"pull_request":{"href":"https://api.github.com/repos/paderinandrey/qna/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/paderinandrey/qna/pulls/7","id":84087642,"html_url":"https://github.com/paderinandrey/qna/pull/7","diff_url":"https://github.com/paderinandrey/qna/pull/7.diff","patch_url":"https://github.com/paderinandrey/qna/pull/7.patch","issue_url":"https://api.github.com/repos/paderinandrey/qna/issues/7","number":7,"state":"open","locked":false,"title":"Voting","user":{"login":"paderinandrey","id":14351695,"avatar_url":"https://avatars.githubusercontent.com/u/14351695?v=3","gravatar_id":"","url":"https://api.github.com/users/paderinandrey","html_url":"https://github.com/paderinandrey","followers_url":"https://api.github.com/users/paderinandrey/followers","following_url":"https://api.github.com/users/paderinandrey/following{/other_user}","gists_url":"https://api.github.com/users/paderinandrey/gists{/gist_id}","starred_url":"https://api.github.com/users/paderinandrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paderinandrey/subscriptions","organizations_url":"https://api.github.com/users/paderinandrey/orgs","repos_url":"https://api.github.com/users/paderinandrey/repos","events_url":"https://api.github.com/users/paderinandrey/events{/privacy}","received_events_url":"https://api.github.com/users/paderinandrey/received_events","type":"User","site_admin":false},"body":"Голосование за вопросы и ответы","created_at":"2016-09-06T09:21:39Z","updated_at":"2016-09-06T10:55:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"990ad0a19e75d2ea9ad61400aebc577e764f8eb4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/paderinandrey/qna/pulls/7/commits","review_comments_url":"https://api.github.com/repos/paderinandrey/qna/pulls/7/comments","review_comment_url":"https://api.github.com/repos/paderinandrey/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paderinandrey/qna/issues/7/comments","statuses_url":"https://api.github.com/repos/paderinandrey/qna/statuses/c31d3d1c977e584293d3c9e2535f12c199b90a65","head":{"label":"paderinandrey:voting","ref":"voting","sha":"c31d3d1c977e584293d3c9e2535f12c199b90a65","user":{"login":"paderinandrey","id":14351695,"avatar_url":"https://avatars.githubusercontent.com/u/14351695?v=3","gravatar_id":"","url":"https://api.github.com/users/paderinandrey","html_url":"https://github.com/paderinandrey","followers_url":"https://api.github.com/users/paderinandrey/followers","following_url":"https://api.github.com/users/paderinandrey/following{/other_user}","gists_url":"https://api.github.com/users/paderinandrey/gists{/gist_id}","starred_url":"https://api.github.com/users/paderinandrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paderinandrey/subscriptions","organizations_url":"https://api.github.com/users/paderinandrey/orgs","repos_url":"https://api.github.com/users/paderinandrey/repos","events_url":"https://api.github.com/users/paderinandrey/events{/privacy}","received_events_url":"https://api.github.com/users/paderinandrey/received_events","type":"User","site_admin":false},"repo":{"id":65100242,"name":"qna","full_name":"paderinandrey/qna","owner":{"login":"paderinandrey","id":14351695,"avatar_url":"https://avatars.githubusercontent.com/u/14351695?v=3","gravatar_id":"","url":"https://api.github.com/users/paderinandrey","html_url":"https://github.com/paderinandrey","followers_url":"https://api.github.com/users/paderinandrey/followers","following_url":"https://api.github.com/users/paderinandrey/following{/other_user}","gists_url":"https://api.github.com/users/paderinandrey/gists{/gist_id}","starred_url":"https://api.github.com/users/paderinandrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paderinandrey/subscriptions","organizations_url":"https://api.github.com/users/paderinandrey/orgs","repos_url":"https://api.github.com/users/paderinandrey/repos","events_url":"https://api.github.com/users/paderinandrey/events{/privacy}","received_events_url":"https://api.github.com/users/paderinandrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paderinandrey/qna","description":null,"fork":false,"url":"https://api.github.com/repos/paderinandrey/qna","forks_url":"https://api.github.com/repos/paderinandrey/qna/forks","keys_url":"https://api.github.com/repos/paderinandrey/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paderinandrey/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paderinandrey/qna/teams","hooks_url":"https://api.github.com/repos/paderinandrey/qna/hooks","issue_events_url":"https://api.github.com/repos/paderinandrey/qna/issues/events{/number}","events_url":"https://api.github.com/repos/paderinandrey/qna/events","assignees_url":"https://api.github.com/repos/paderinandrey/qna/assignees{/user}","branches_url":"https://api.github.com/repos/paderinandrey/qna/branches{/branch}","tags_url":"https://api.github.com/repos/paderinandrey/qna/tags","blobs_url":"https://api.github.com/repos/paderinandrey/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paderinandrey/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paderinandrey/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/paderinandrey/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paderinandrey/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/paderinandrey/qna/languages","stargazers_url":"https://api.github.com/repos/paderinandrey/qna/stargazers","contributors_url":"https://api.github.com/repos/paderinandrey/qna/contributors","subscribers_url":"https://api.github.com/repos/paderinandrey/qna/subscribers","subscription_url":"https://api.github.com/repos/paderinandrey/qna/subscription","commits_url":"https://api.github.com/repos/paderinandrey/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/paderinandrey/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/paderinandrey/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/paderinandrey/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/paderinandrey/qna/contents/{+path}","compare_url":"https://api.github.com/repos/paderinandrey/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paderinandrey/qna/merges","archive_url":"https://api.github.com/repos/paderinandrey/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paderinandrey/qna/downloads","issues_url":"https://api.github.com/repos/paderinandrey/qna/issues{/number}","pulls_url":"https://api.github.com/repos/paderinandrey/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/paderinandrey/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/paderinandrey/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paderinandrey/qna/labels{/name}","releases_url":"https://api.github.com/repos/paderinandrey/qna/releases{/id}","deployments_url":"https://api.github.com/repos/paderinandrey/qna/deployments","created_at":"2016-08-06T20:12:29Z","updated_at":"2016-08-06T21:44:11Z","pushed_at":"2016-09-06T09:21:39Z","git_url":"git://github.com/paderinandrey/qna.git","ssh_url":"git@github.com:paderinandrey/qna.git","clone_url":"https://github.com/paderinandrey/qna.git","svn_url":"https://github.com/paderinandrey/qna","homepage":null,"size":124,"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":"paderinandrey:master","ref":"master","sha":"328ac5e318f82a9dd70cf2663c23363a641bfad5","user":{"login":"paderinandrey","id":14351695,"avatar_url":"https://avatars.githubusercontent.com/u/14351695?v=3","gravatar_id":"","url":"https://api.github.com/users/paderinandrey","html_url":"https://github.com/paderinandrey","followers_url":"https://api.github.com/users/paderinandrey/followers","following_url":"https://api.github.com/users/paderinandrey/following{/other_user}","gists_url":"https://api.github.com/users/paderinandrey/gists{/gist_id}","starred_url":"https://api.github.com/users/paderinandrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paderinandrey/subscriptions","organizations_url":"https://api.github.com/users/paderinandrey/orgs","repos_url":"https://api.github.com/users/paderinandrey/repos","events_url":"https://api.github.com/users/paderinandrey/events{/privacy}","received_events_url":"https://api.github.com/users/paderinandrey/received_events","type":"User","site_admin":false},"repo":{"id":65100242,"name":"qna","full_name":"paderinandrey/qna","owner":{"login":"paderinandrey","id":14351695,"avatar_url":"https://avatars.githubusercontent.com/u/14351695?v=3","gravatar_id":"","url":"https://api.github.com/users/paderinandrey","html_url":"https://github.com/paderinandrey","followers_url":"https://api.github.com/users/paderinandrey/followers","following_url":"https://api.github.com/users/paderinandrey/following{/other_user}","gists_url":"https://api.github.com/users/paderinandrey/gists{/gist_id}","starred_url":"https://api.github.com/users/paderinandrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paderinandrey/subscriptions","organizations_url":"https://api.github.com/users/paderinandrey/orgs","repos_url":"https://api.github.com/users/paderinandrey/repos","events_url":"https://api.github.com/users/paderinandrey/events{/privacy}","received_events_url":"https://api.github.com/users/paderinandrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paderinandrey/qna","description":null,"fork":false,"url":"https://api.github.com/repos/paderinandrey/qna","forks_url":"https://api.github.com/repos/paderinandrey/qna/forks","keys_url":"https://api.github.com/repos/paderinandrey/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paderinandrey/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paderinandrey/qna/teams","hooks_url":"https://api.github.com/repos/paderinandrey/qna/hooks","issue_events_url":"https://api.github.com/repos/paderinandrey/qna/issues/events{/number}","events_url":"https://api.github.com/repos/paderinandrey/qna/events","assignees_url":"https://api.github.com/repos/paderinandrey/qna/assignees{/user}","branches_url":"https://api.github.com/repos/paderinandrey/qna/branches{/branch}","tags_url":"https://api.github.com/repos/paderinandrey/qna/tags","blobs_url":"https://api.github.com/repos/paderinandrey/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paderinandrey/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paderinandrey/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/paderinandrey/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paderinandrey/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/paderinandrey/qna/languages","stargazers_url":"https://api.github.com/repos/paderinandrey/qna/stargazers","contributors_url":"https://api.github.com/repos/paderinandrey/qna/contributors","subscribers_url":"https://api.github.com/repos/paderinandrey/qna/subscribers","subscription_url":"https://api.github.com/repos/paderinandrey/qna/subscription","commits_url":"https://api.github.com/repos/paderinandrey/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/paderinandrey/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/paderinandrey/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/paderinandrey/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/paderinandrey/qna/contents/{+path}","compare_url":"https://api.github.com/repos/paderinandrey/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paderinandrey/qna/merges","archive_url":"https://api.github.com/repos/paderinandrey/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paderinandrey/qna/downloads","issues_url":"https://api.github.com/repos/paderinandrey/qna/issues{/number}","pulls_url":"https://api.github.com/repos/paderinandrey/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/paderinandrey/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/paderinandrey/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paderinandrey/qna/labels{/name}","releases_url":"https://api.github.com/repos/paderinandrey/qna/releases{/id}","deployments_url":"https://api.github.com/repos/paderinandrey/qna/deployments","created_at":"2016-08-06T20:12:29Z","updated_at":"2016-08-06T21:44:11Z","pushed_at":"2016-09-06T09:21:39Z","git_url":"git://github.com/paderinandrey/qna.git","ssh_url":"git@github.com:paderinandrey/qna.git","clone_url":"https://github.com/paderinandrey/qna.git","svn_url":"https://github.com/paderinandrey/qna","homepage":null,"size":124,"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/paderinandrey/qna/pulls/7"},"html":{"href":"https://github.com/paderinandrey/qna/pull/7"},"issue":{"href":"https://api.github.com/repos/paderinandrey/qna/issues/7"},"comments":{"href":"https://api.github.com/repos/paderinandrey/qna/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/paderinandrey/qna/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/paderinandrey/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paderinandrey/qna/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/paderinandrey/qna/statuses/c31d3d1c977e584293d3c9e2535f12c199b90a65"}}}}
{"actor":{"display_login":"vkurennov"}}