{"action":"created","comment":{"url":"https://api.github.com/repos/rohellec/qna/pulls/comments/181979687","pull_request_review_id":112697730,"id":181979687,"diff_hunk":"@@ -1,27 +1,38 @@\n class AnswersController < ApplicationController\n-  before_action :set_question, only: [:new, :create]\n-\n-  def new\n-    @answer = Answer.new\n-  end\n+  before_action :authenticate_user!\n+  before_action :set_question,  only: :create\n+  before_action :correct_user?, only: :destroy\n \n   def create\n     @answer = @question.answers.build(answer_params)\n+    @answer.user = current_user\n     if @answer.save\n       flash[:success] = \"New answer has been successfully created\"\n       redirect_to @question\n     else\n-      render :new\n+      render \"questions/show\"\n     end\n   end\n \n-  private\n-\n-  def set_question\n-    @question = Question.find(params[:question_id])\n+  def destroy\n+    @answer.destroy\n+    flash[:success] = \"Answer has been successfully deleted\"\n+    redirect_to @answer.question\n   end\n \n+  private\n+\n   def answer_params\n     params.require(:answer).permit(:body)\n   end\n+\n+  def correct_user?\n+    @answer = Answer.find(params[:id])\n+    redirect_to root_path unless current_user.author_of?(@answer)","path":"app/controllers/answers_controller.rb","position":41,"original_position":41,"commit_id":"c841961e3abf323032a03f7e20d1fe5d9e46a5f2","original_commit_id":"c841961e3abf323032a03f7e20d1fe5d9e46a5f2","user":{"login":"vkurennov","id":968537,"avatar_url":"https://avatars3.githubusercontent.com/u/968537?v=4","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":"Тут хорошо бы сообщение какое-то написать, и лучше, конечно не делать сразу на root_path редирект, а не ту страницу, с которой и был сделан запрос","created_at":"2018-04-17T07:48:18Z","updated_at":"2018-04-17T07:52:17Z","html_url":"https://github.com/rohellec/qna/pull/3#discussion_r181979687","pull_request_url":"https://api.github.com/repos/rohellec/qna/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rohellec/qna/pulls/comments/181979687"},"html":{"href":"https://github.com/rohellec/qna/pull/3#discussion_r181979687"},"pull_request":{"href":"https://api.github.com/repos/rohellec/qna/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/rohellec/qna/pulls/3","id":181536642,"html_url":"https://github.com/rohellec/qna/pull/3","diff_url":"https://github.com/rohellec/qna/pull/3.diff","patch_url":"https://github.com/rohellec/qna/pull/3.patch","issue_url":"https://api.github.com/repos/rohellec/qna/issues/3","number":3,"state":"open","locked":false,"title":"Acceptance testing","user":{"login":"rohellec","id":12073846,"avatar_url":"https://avatars1.githubusercontent.com/u/12073846?v=4","gravatar_id":"","url":"https://api.github.com/users/rohellec","html_url":"https://github.com/rohellec","followers_url":"https://api.github.com/users/rohellec/followers","following_url":"https://api.github.com/users/rohellec/following{/other_user}","gists_url":"https://api.github.com/users/rohellec/gists{/gist_id}","starred_url":"https://api.github.com/users/rohellec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohellec/subscriptions","organizations_url":"https://api.github.com/users/rohellec/orgs","repos_url":"https://api.github.com/users/rohellec/repos","events_url":"https://api.github.com/users/rohellec/events{/privacy}","received_events_url":"https://api.github.com/users/rohellec/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-13T16:26:49Z","updated_at":"2018-04-17T07:52:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e84a4cd0822b1833024bd9ca88304cffa640cf6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rohellec/qna/pulls/3/commits","review_comments_url":"https://api.github.com/repos/rohellec/qna/pulls/3/comments","review_comment_url":"https://api.github.com/repos/rohellec/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rohellec/qna/issues/3/comments","statuses_url":"https://api.github.com/repos/rohellec/qna/statuses/c841961e3abf323032a03f7e20d1fe5d9e46a5f2","head":{"label":"rohellec:acceptance_testing","ref":"acceptance_testing","sha":"c841961e3abf323032a03f7e20d1fe5d9e46a5f2","user":{"login":"rohellec","id":12073846,"avatar_url":"https://avatars1.githubusercontent.com/u/12073846?v=4","gravatar_id":"","url":"https://api.github.com/users/rohellec","html_url":"https://github.com/rohellec","followers_url":"https://api.github.com/users/rohellec/followers","following_url":"https://api.github.com/users/rohellec/following{/other_user}","gists_url":"https://api.github.com/users/rohellec/gists{/gist_id}","starred_url":"https://api.github.com/users/rohellec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohellec/subscriptions","organizations_url":"https://api.github.com/users/rohellec/orgs","repos_url":"https://api.github.com/users/rohellec/repos","events_url":"https://api.github.com/users/rohellec/events{/privacy}","received_events_url":"https://api.github.com/users/rohellec/received_events","type":"User","site_admin":false},"repo":{"id":124697229,"name":"qna","full_name":"rohellec/qna","owner":{"login":"rohellec","id":12073846,"avatar_url":"https://avatars1.githubusercontent.com/u/12073846?v=4","gravatar_id":"","url":"https://api.github.com/users/rohellec","html_url":"https://github.com/rohellec","followers_url":"https://api.github.com/users/rohellec/followers","following_url":"https://api.github.com/users/rohellec/following{/other_user}","gists_url":"https://api.github.com/users/rohellec/gists{/gist_id}","starred_url":"https://api.github.com/users/rohellec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohellec/subscriptions","organizations_url":"https://api.github.com/users/rohellec/orgs","repos_url":"https://api.github.com/users/rohellec/repos","events_url":"https://api.github.com/users/rohellec/events{/privacy}","received_events_url":"https://api.github.com/users/rohellec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rohellec/qna","description":"Q&A application","fork":false,"url":"https://api.github.com/repos/rohellec/qna","forks_url":"https://api.github.com/repos/rohellec/qna/forks","keys_url":"https://api.github.com/repos/rohellec/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rohellec/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rohellec/qna/teams","hooks_url":"https://api.github.com/repos/rohellec/qna/hooks","issue_events_url":"https://api.github.com/repos/rohellec/qna/issues/events{/number}","events_url":"https://api.github.com/repos/rohellec/qna/events","assignees_url":"https://api.github.com/repos/rohellec/qna/assignees{/user}","branches_url":"https://api.github.com/repos/rohellec/qna/branches{/branch}","tags_url":"https://api.github.com/repos/rohellec/qna/tags","blobs_url":"https://api.github.com/repos/rohellec/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rohellec/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rohellec/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/rohellec/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rohellec/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/rohellec/qna/languages","stargazers_url":"https://api.github.com/repos/rohellec/qna/stargazers","contributors_url":"https://api.github.com/repos/rohellec/qna/contributors","subscribers_url":"https://api.github.com/repos/rohellec/qna/subscribers","subscription_url":"https://api.github.com/repos/rohellec/qna/subscription","commits_url":"https://api.github.com/repos/rohellec/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/rohellec/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/rohellec/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/rohellec/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/rohellec/qna/contents/{+path}","compare_url":"https://api.github.com/repos/rohellec/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rohellec/qna/merges","archive_url":"https://api.github.com/repos/rohellec/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rohellec/qna/downloads","issues_url":"https://api.github.com/repos/rohellec/qna/issues{/number}","pulls_url":"https://api.github.com/repos/rohellec/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/rohellec/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/rohellec/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rohellec/qna/labels{/name}","releases_url":"https://api.github.com/repos/rohellec/qna/releases{/id}","deployments_url":"https://api.github.com/repos/rohellec/qna/deployments","created_at":"2018-03-10T20:47:23Z","updated_at":"2018-03-26T20:39:15Z","pushed_at":"2018-04-16T15:44:19Z","git_url":"git://github.com/rohellec/qna.git","ssh_url":"git@github.com:rohellec/qna.git","clone_url":"https://github.com/rohellec/qna.git","svn_url":"https://github.com/rohellec/qna","homepage":null,"size":88,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rohellec:master","ref":"master","sha":"a7a7380ccac4442185a7947b3cbc677ae6f6a7de","user":{"login":"rohellec","id":12073846,"avatar_url":"https://avatars1.githubusercontent.com/u/12073846?v=4","gravatar_id":"","url":"https://api.github.com/users/rohellec","html_url":"https://github.com/rohellec","followers_url":"https://api.github.com/users/rohellec/followers","following_url":"https://api.github.com/users/rohellec/following{/other_user}","gists_url":"https://api.github.com/users/rohellec/gists{/gist_id}","starred_url":"https://api.github.com/users/rohellec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohellec/subscriptions","organizations_url":"https://api.github.com/users/rohellec/orgs","repos_url":"https://api.github.com/users/rohellec/repos","events_url":"https://api.github.com/users/rohellec/events{/privacy}","received_events_url":"https://api.github.com/users/rohellec/received_events","type":"User","site_admin":false},"repo":{"id":124697229,"name":"qna","full_name":"rohellec/qna","owner":{"login":"rohellec","id":12073846,"avatar_url":"https://avatars1.githubusercontent.com/u/12073846?v=4","gravatar_id":"","url":"https://api.github.com/users/rohellec","html_url":"https://github.com/rohellec","followers_url":"https://api.github.com/users/rohellec/followers","following_url":"https://api.github.com/users/rohellec/following{/other_user}","gists_url":"https://api.github.com/users/rohellec/gists{/gist_id}","starred_url":"https://api.github.com/users/rohellec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohellec/subscriptions","organizations_url":"https://api.github.com/users/rohellec/orgs","repos_url":"https://api.github.com/users/rohellec/repos","events_url":"https://api.github.com/users/rohellec/events{/privacy}","received_events_url":"https://api.github.com/users/rohellec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rohellec/qna","description":"Q&A application","fork":false,"url":"https://api.github.com/repos/rohellec/qna","forks_url":"https://api.github.com/repos/rohellec/qna/forks","keys_url":"https://api.github.com/repos/rohellec/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rohellec/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rohellec/qna/teams","hooks_url":"https://api.github.com/repos/rohellec/qna/hooks","issue_events_url":"https://api.github.com/repos/rohellec/qna/issues/events{/number}","events_url":"https://api.github.com/repos/rohellec/qna/events","assignees_url":"https://api.github.com/repos/rohellec/qna/assignees{/user}","branches_url":"https://api.github.com/repos/rohellec/qna/branches{/branch}","tags_url":"https://api.github.com/repos/rohellec/qna/tags","blobs_url":"https://api.github.com/repos/rohellec/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rohellec/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rohellec/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/rohellec/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rohellec/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/rohellec/qna/languages","stargazers_url":"https://api.github.com/repos/rohellec/qna/stargazers","contributors_url":"https://api.github.com/repos/rohellec/qna/contributors","subscribers_url":"https://api.github.com/repos/rohellec/qna/subscribers","subscription_url":"https://api.github.com/repos/rohellec/qna/subscription","commits_url":"https://api.github.com/repos/rohellec/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/rohellec/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/rohellec/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/rohellec/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/rohellec/qna/contents/{+path}","compare_url":"https://api.github.com/repos/rohellec/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rohellec/qna/merges","archive_url":"https://api.github.com/repos/rohellec/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rohellec/qna/downloads","issues_url":"https://api.github.com/repos/rohellec/qna/issues{/number}","pulls_url":"https://api.github.com/repos/rohellec/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/rohellec/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/rohellec/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rohellec/qna/labels{/name}","releases_url":"https://api.github.com/repos/rohellec/qna/releases{/id}","deployments_url":"https://api.github.com/repos/rohellec/qna/deployments","created_at":"2018-03-10T20:47:23Z","updated_at":"2018-03-26T20:39:15Z","pushed_at":"2018-04-16T15:44:19Z","git_url":"git://github.com/rohellec/qna.git","ssh_url":"git@github.com:rohellec/qna.git","clone_url":"https://github.com/rohellec/qna.git","svn_url":"https://github.com/rohellec/qna","homepage":null,"size":88,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rohellec/qna/pulls/3"},"html":{"href":"https://github.com/rohellec/qna/pull/3"},"issue":{"href":"https://api.github.com/repos/rohellec/qna/issues/3"},"comments":{"href":"https://api.github.com/repos/rohellec/qna/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/rohellec/qna/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/rohellec/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rohellec/qna/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/rohellec/qna/statuses/c841961e3abf323032a03f7e20d1fe5d9e46a5f2"}},"author_association":"OWNER"}}
{"actor":{"display_login":"vkurennov"}}