{"action":"created","comment":{"url":"https://api.github.com/repos/zlahham/live-voting/pulls/comments/40508510","id":40508510,"diff_hunk":"@@ -26,6 +26,16 @@ def destroy\n     flash[:notice] = \"Question successfully deleted\" \n   end\n \n+  def clear_votes\n+    question = Question.find(params[:id])\n+    if question.choices.map{ |choice| choice.votes.destroy_all }\n+      redirect_to question_path(question)\n+      flash[:notice] = \"Votes successfully cleared\"\n+    else\n+      flash[:alert] = \"Error clearing votes\"","path":"app/controllers/questions_controller.rb","position":null,"original_position":10,"commit_id":"ce48fd4dd00e065fb245affc1f875b047daaf348","original_commit_id":"79f96703fc3af916086d1af0cc943a949de2e572","user":{"login":"Yorkshireman","id":8686588,"avatar_url":"https://avatars.githubusercontent.com/u/8686588?v=3","gravatar_id":"","url":"https://api.github.com/users/Yorkshireman","html_url":"https://github.com/Yorkshireman","followers_url":"https://api.github.com/users/Yorkshireman/followers","following_url":"https://api.github.com/users/Yorkshireman/following{/other_user}","gists_url":"https://api.github.com/users/Yorkshireman/gists{/gist_id}","starred_url":"https://api.github.com/users/Yorkshireman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yorkshireman/subscriptions","organizations_url":"https://api.github.com/users/Yorkshireman/orgs","repos_url":"https://api.github.com/users/Yorkshireman/repos","events_url":"https://api.github.com/users/Yorkshireman/events{/privacy}","received_events_url":"https://api.github.com/users/Yorkshireman/received_events","type":"User","site_admin":false},"body":"It's not absolutely perfect because, even though no-one can access the button in the view if there are no votes, in theory someone could run the method somehow and it would still say 'votes cleared' even when there weren't any votes, but all-in-all it's a moot point I think.","created_at":"2015-09-27T19:35:37Z","updated_at":"2015-09-27T19:35:37Z","html_url":"https://github.com/zlahham/live-voting/pull/159#discussion_r40508510","pull_request_url":"https://api.github.com/repos/zlahham/live-voting/pulls/159","_links":{"self":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/comments/40508510"},"html":{"href":"https://github.com/zlahham/live-voting/pull/159#discussion_r40508510"},"pull_request":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/zlahham/live-voting/pulls/159","id":46093210,"html_url":"https://github.com/zlahham/live-voting/pull/159","diff_url":"https://github.com/zlahham/live-voting/pull/159.diff","patch_url":"https://github.com/zlahham/live-voting/pull/159.patch","issue_url":"https://api.github.com/repos/zlahham/live-voting/issues/159","number":159,"state":"open","locked":false,"title":"156-clear-votes","user":{"login":"Yorkshireman","id":8686588,"avatar_url":"https://avatars.githubusercontent.com/u/8686588?v=3","gravatar_id":"","url":"https://api.github.com/users/Yorkshireman","html_url":"https://github.com/Yorkshireman","followers_url":"https://api.github.com/users/Yorkshireman/followers","following_url":"https://api.github.com/users/Yorkshireman/following{/other_user}","gists_url":"https://api.github.com/users/Yorkshireman/gists{/gist_id}","starred_url":"https://api.github.com/users/Yorkshireman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yorkshireman/subscriptions","organizations_url":"https://api.github.com/users/Yorkshireman/orgs","repos_url":"https://api.github.com/users/Yorkshireman/repos","events_url":"https://api.github.com/users/Yorkshireman/events{/privacy}","received_events_url":"https://api.github.com/users/Yorkshireman/received_events","type":"User","site_admin":false},"body":"close #156","created_at":"2015-09-27T01:35:52Z","updated_at":"2015-09-27T19:35:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ae77a2edf25f6903eea0e0cb50b895287bbd247","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zlahham/live-voting/pulls/159/commits","review_comments_url":"https://api.github.com/repos/zlahham/live-voting/pulls/159/comments","review_comment_url":"https://api.github.com/repos/zlahham/live-voting/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zlahham/live-voting/issues/159/comments","statuses_url":"https://api.github.com/repos/zlahham/live-voting/statuses/ce48fd4dd00e065fb245affc1f875b047daaf348","head":{"label":"zlahham:156-clear-votes","ref":"156-clear-votes","sha":"ce48fd4dd00e065fb245affc1f875b047daaf348","user":{"login":"zlahham","id":10406173,"avatar_url":"https://avatars.githubusercontent.com/u/10406173?v=3","gravatar_id":"","url":"https://api.github.com/users/zlahham","html_url":"https://github.com/zlahham","followers_url":"https://api.github.com/users/zlahham/followers","following_url":"https://api.github.com/users/zlahham/following{/other_user}","gists_url":"https://api.github.com/users/zlahham/gists{/gist_id}","starred_url":"https://api.github.com/users/zlahham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zlahham/subscriptions","organizations_url":"https://api.github.com/users/zlahham/orgs","repos_url":"https://api.github.com/users/zlahham/repos","events_url":"https://api.github.com/users/zlahham/events{/privacy}","received_events_url":"https://api.github.com/users/zlahham/received_events","type":"User","site_admin":false},"repo":{"id":42860809,"name":"live-voting","full_name":"zlahham/live-voting","owner":{"login":"zlahham","id":10406173,"avatar_url":"https://avatars.githubusercontent.com/u/10406173?v=3","gravatar_id":"","url":"https://api.github.com/users/zlahham","html_url":"https://github.com/zlahham","followers_url":"https://api.github.com/users/zlahham/followers","following_url":"https://api.github.com/users/zlahham/following{/other_user}","gists_url":"https://api.github.com/users/zlahham/gists{/gist_id}","starred_url":"https://api.github.com/users/zlahham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zlahham/subscriptions","organizations_url":"https://api.github.com/users/zlahham/orgs","repos_url":"https://api.github.com/users/zlahham/repos","events_url":"https://api.github.com/users/zlahham/events{/privacy}","received_events_url":"https://api.github.com/users/zlahham/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zlahham/live-voting","description":"","fork":false,"url":"https://api.github.com/repos/zlahham/live-voting","forks_url":"https://api.github.com/repos/zlahham/live-voting/forks","keys_url":"https://api.github.com/repos/zlahham/live-voting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zlahham/live-voting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zlahham/live-voting/teams","hooks_url":"https://api.github.com/repos/zlahham/live-voting/hooks","issue_events_url":"https://api.github.com/repos/zlahham/live-voting/issues/events{/number}","events_url":"https://api.github.com/repos/zlahham/live-voting/events","assignees_url":"https://api.github.com/repos/zlahham/live-voting/assignees{/user}","branches_url":"https://api.github.com/repos/zlahham/live-voting/branches{/branch}","tags_url":"https://api.github.com/repos/zlahham/live-voting/tags","blobs_url":"https://api.github.com/repos/zlahham/live-voting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zlahham/live-voting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zlahham/live-voting/git/refs{/sha}","trees_url":"https://api.github.com/repos/zlahham/live-voting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zlahham/live-voting/statuses/{sha}","languages_url":"https://api.github.com/repos/zlahham/live-voting/languages","stargazers_url":"https://api.github.com/repos/zlahham/live-voting/stargazers","contributors_url":"https://api.github.com/repos/zlahham/live-voting/contributors","subscribers_url":"https://api.github.com/repos/zlahham/live-voting/subscribers","subscription_url":"https://api.github.com/repos/zlahham/live-voting/subscription","commits_url":"https://api.github.com/repos/zlahham/live-voting/commits{/sha}","git_commits_url":"https://api.github.com/repos/zlahham/live-voting/git/commits{/sha}","comments_url":"https://api.github.com/repos/zlahham/live-voting/comments{/number}","issue_comment_url":"https://api.github.com/repos/zlahham/live-voting/issues/comments{/number}","contents_url":"https://api.github.com/repos/zlahham/live-voting/contents/{+path}","compare_url":"https://api.github.com/repos/zlahham/live-voting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zlahham/live-voting/merges","archive_url":"https://api.github.com/repos/zlahham/live-voting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zlahham/live-voting/downloads","issues_url":"https://api.github.com/repos/zlahham/live-voting/issues{/number}","pulls_url":"https://api.github.com/repos/zlahham/live-voting/pulls{/number}","milestones_url":"https://api.github.com/repos/zlahham/live-voting/milestones{/number}","notifications_url":"https://api.github.com/repos/zlahham/live-voting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zlahham/live-voting/labels{/name}","releases_url":"https://api.github.com/repos/zlahham/live-voting/releases{/id}","created_at":"2015-09-21T10:56:29Z","updated_at":"2015-09-26T01:10:50Z","pushed_at":"2015-09-27T19:33:23Z","git_url":"git://github.com/zlahham/live-voting.git","ssh_url":"git@github.com:zlahham/live-voting.git","clone_url":"https://github.com/zlahham/live-voting.git","svn_url":"https://github.com/zlahham/live-voting","homepage":null,"size":2533,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":33,"forks":0,"open_issues":33,"watchers":3,"default_branch":"master"}},"base":{"label":"zlahham:master","ref":"master","sha":"58b3fd51d53a7e9aa18dab05014a77eb8c243c26","user":{"login":"zlahham","id":10406173,"avatar_url":"https://avatars.githubusercontent.com/u/10406173?v=3","gravatar_id":"","url":"https://api.github.com/users/zlahham","html_url":"https://github.com/zlahham","followers_url":"https://api.github.com/users/zlahham/followers","following_url":"https://api.github.com/users/zlahham/following{/other_user}","gists_url":"https://api.github.com/users/zlahham/gists{/gist_id}","starred_url":"https://api.github.com/users/zlahham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zlahham/subscriptions","organizations_url":"https://api.github.com/users/zlahham/orgs","repos_url":"https://api.github.com/users/zlahham/repos","events_url":"https://api.github.com/users/zlahham/events{/privacy}","received_events_url":"https://api.github.com/users/zlahham/received_events","type":"User","site_admin":false},"repo":{"id":42860809,"name":"live-voting","full_name":"zlahham/live-voting","owner":{"login":"zlahham","id":10406173,"avatar_url":"https://avatars.githubusercontent.com/u/10406173?v=3","gravatar_id":"","url":"https://api.github.com/users/zlahham","html_url":"https://github.com/zlahham","followers_url":"https://api.github.com/users/zlahham/followers","following_url":"https://api.github.com/users/zlahham/following{/other_user}","gists_url":"https://api.github.com/users/zlahham/gists{/gist_id}","starred_url":"https://api.github.com/users/zlahham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zlahham/subscriptions","organizations_url":"https://api.github.com/users/zlahham/orgs","repos_url":"https://api.github.com/users/zlahham/repos","events_url":"https://api.github.com/users/zlahham/events{/privacy}","received_events_url":"https://api.github.com/users/zlahham/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zlahham/live-voting","description":"","fork":false,"url":"https://api.github.com/repos/zlahham/live-voting","forks_url":"https://api.github.com/repos/zlahham/live-voting/forks","keys_url":"https://api.github.com/repos/zlahham/live-voting/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zlahham/live-voting/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zlahham/live-voting/teams","hooks_url":"https://api.github.com/repos/zlahham/live-voting/hooks","issue_events_url":"https://api.github.com/repos/zlahham/live-voting/issues/events{/number}","events_url":"https://api.github.com/repos/zlahham/live-voting/events","assignees_url":"https://api.github.com/repos/zlahham/live-voting/assignees{/user}","branches_url":"https://api.github.com/repos/zlahham/live-voting/branches{/branch}","tags_url":"https://api.github.com/repos/zlahham/live-voting/tags","blobs_url":"https://api.github.com/repos/zlahham/live-voting/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zlahham/live-voting/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zlahham/live-voting/git/refs{/sha}","trees_url":"https://api.github.com/repos/zlahham/live-voting/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zlahham/live-voting/statuses/{sha}","languages_url":"https://api.github.com/repos/zlahham/live-voting/languages","stargazers_url":"https://api.github.com/repos/zlahham/live-voting/stargazers","contributors_url":"https://api.github.com/repos/zlahham/live-voting/contributors","subscribers_url":"https://api.github.com/repos/zlahham/live-voting/subscribers","subscription_url":"https://api.github.com/repos/zlahham/live-voting/subscription","commits_url":"https://api.github.com/repos/zlahham/live-voting/commits{/sha}","git_commits_url":"https://api.github.com/repos/zlahham/live-voting/git/commits{/sha}","comments_url":"https://api.github.com/repos/zlahham/live-voting/comments{/number}","issue_comment_url":"https://api.github.com/repos/zlahham/live-voting/issues/comments{/number}","contents_url":"https://api.github.com/repos/zlahham/live-voting/contents/{+path}","compare_url":"https://api.github.com/repos/zlahham/live-voting/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zlahham/live-voting/merges","archive_url":"https://api.github.com/repos/zlahham/live-voting/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zlahham/live-voting/downloads","issues_url":"https://api.github.com/repos/zlahham/live-voting/issues{/number}","pulls_url":"https://api.github.com/repos/zlahham/live-voting/pulls{/number}","milestones_url":"https://api.github.com/repos/zlahham/live-voting/milestones{/number}","notifications_url":"https://api.github.com/repos/zlahham/live-voting/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zlahham/live-voting/labels{/name}","releases_url":"https://api.github.com/repos/zlahham/live-voting/releases{/id}","created_at":"2015-09-21T10:56:29Z","updated_at":"2015-09-26T01:10:50Z","pushed_at":"2015-09-27T19:33:23Z","git_url":"git://github.com/zlahham/live-voting.git","ssh_url":"git@github.com:zlahham/live-voting.git","clone_url":"https://github.com/zlahham/live-voting.git","svn_url":"https://github.com/zlahham/live-voting","homepage":null,"size":2533,"stargazers_count":3,"watchers_count":3,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":33,"forks":0,"open_issues":33,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/159"},"html":{"href":"https://github.com/zlahham/live-voting/pull/159"},"issue":{"href":"https://api.github.com/repos/zlahham/live-voting/issues/159"},"comments":{"href":"https://api.github.com/repos/zlahham/live-voting/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zlahham/live-voting/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/zlahham/live-voting/statuses/ce48fd4dd00e065fb245affc1f875b047daaf348"}}}}