{"action":"created","comment":{"url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/comments/52157748","id":52157748,"diff_hunk":"@@ -1,23 +1,73 @@\n class AnswersController < ApplicationController\n-  before_action :authenticate_user!, only: [:new, :create]\n+  before_action :authenticate_user!, only: [:edit, :destroy]\n+  before_action :load_answer, only: [:edit, :update, :destroy]\n+  before_action :check_edit_rights, only: [:edit]\n+\n \n-  def new\n-    @answer = Answer.new\n-  end\n \n   def create\n     @question = Question.find(params[:question_id])\n     @answer = @question.answers.new(answer_params)\n     @answer.user = current_user\n-    if @answer.save\n-      redirect_to @question\n-    else\n-      render :new\n+    @signed_in = false\n+    if user_signed_in?\n+       @answer.save\n+       @signed_in = true\n     end\n+    # if @answer.save\n+    #   redirect_to @question\n+    # else\n+    #   @question.reload\n+    #   render 'questions/show'\n+    # end\n   end\n \n+  def edit\n+  end\n+\n+  def update\n+    @has_rights = false\n+    @signed_in = false\n+    if user_signed_in?\n+       @signed_in = true\n+       if current_user.can_edit?(@answer)\n+         @has_rights = true\n+         @answer.update(answer_params)\n+       end\n+    end\n+    # if @answer.update(answer_params)\n+    #   redirect_to @answer.question\n+    # else\n+    #   render :edit\n+    # end\n+  end\n+\n+  def destroy\n+    @has_rights = false\n+    @signed_in = false\n+    if user_signed_in?","path":"app/controllers/answers_controller.rb","position":56,"original_position":56,"commit_id":"255075d3b0153b41968c08bfa31033a95f0c197b","original_commit_id":"255075d3b0153b41968c08bfa31033a95f0c197b","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":"Опять же,  authenticate_user! спасет отца русской демократии :-)","created_at":"2016-02-08T11:24:36Z","updated_at":"2016-02-08T11:24:36Z","html_url":"https://github.com/antonkoh/questionanswer/pull/20#discussion_r52157748","pull_request_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/comments/52157748"},"html":{"href":"https://github.com/antonkoh/questionanswer/pull/20#discussion_r52157748"},"pull_request":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20","id":57904101,"html_url":"https://github.com/antonkoh/questionanswer/pull/20","diff_url":"https://github.com/antonkoh/questionanswer/pull/20.diff","patch_url":"https://github.com/antonkoh/questionanswer/pull/20.patch","issue_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/20","number":20,"state":"open","locked":false,"title":"Lesson27","user":{"login":"antonkoh","id":14329340,"avatar_url":"https://avatars.githubusercontent.com/u/14329340?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkoh","html_url":"https://github.com/antonkoh","followers_url":"https://api.github.com/users/antonkoh/followers","following_url":"https://api.github.com/users/antonkoh/following{/other_user}","gists_url":"https://api.github.com/users/antonkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkoh/subscriptions","organizations_url":"https://api.github.com/users/antonkoh/orgs","repos_url":"https://api.github.com/users/antonkoh/repos","events_url":"https://api.github.com/users/antonkoh/events{/privacy}","received_events_url":"https://api.github.com/users/antonkoh/received_events","type":"User","site_admin":false},"body":"Я немного ошибся с заданиями и в этом задании заодно сделал синхронные методы для следующего домашнего задания.\r\nАсинхронные только те, которые нужны.","created_at":"2016-02-01T21:38:54Z","updated_at":"2016-02-08T11:24:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e17e6d5440dd7d71d3e4cd55c3955db244f5d9c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20/commits","review_comments_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20/comments","review_comment_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/20/comments","statuses_url":"https://api.github.com/repos/antonkoh/questionanswer/statuses/255075d3b0153b41968c08bfa31033a95f0c197b","head":{"label":"antonkoh:Lesson27","ref":"Lesson27","sha":"255075d3b0153b41968c08bfa31033a95f0c197b","user":{"login":"antonkoh","id":14329340,"avatar_url":"https://avatars.githubusercontent.com/u/14329340?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkoh","html_url":"https://github.com/antonkoh","followers_url":"https://api.github.com/users/antonkoh/followers","following_url":"https://api.github.com/users/antonkoh/following{/other_user}","gists_url":"https://api.github.com/users/antonkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkoh/subscriptions","organizations_url":"https://api.github.com/users/antonkoh/orgs","repos_url":"https://api.github.com/users/antonkoh/repos","events_url":"https://api.github.com/users/antonkoh/events{/privacy}","received_events_url":"https://api.github.com/users/antonkoh/received_events","type":"User","site_admin":false},"repo":{"id":50259189,"name":"questionanswer","full_name":"antonkoh/questionanswer","owner":{"login":"antonkoh","id":14329340,"avatar_url":"https://avatars.githubusercontent.com/u/14329340?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkoh","html_url":"https://github.com/antonkoh","followers_url":"https://api.github.com/users/antonkoh/followers","following_url":"https://api.github.com/users/antonkoh/following{/other_user}","gists_url":"https://api.github.com/users/antonkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkoh/subscriptions","organizations_url":"https://api.github.com/users/antonkoh/orgs","repos_url":"https://api.github.com/users/antonkoh/repos","events_url":"https://api.github.com/users/antonkoh/events{/privacy}","received_events_url":"https://api.github.com/users/antonkoh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antonkoh/questionanswer","description":"","fork":false,"url":"https://api.github.com/repos/antonkoh/questionanswer","forks_url":"https://api.github.com/repos/antonkoh/questionanswer/forks","keys_url":"https://api.github.com/repos/antonkoh/questionanswer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antonkoh/questionanswer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antonkoh/questionanswer/teams","hooks_url":"https://api.github.com/repos/antonkoh/questionanswer/hooks","issue_events_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/events{/number}","events_url":"https://api.github.com/repos/antonkoh/questionanswer/events","assignees_url":"https://api.github.com/repos/antonkoh/questionanswer/assignees{/user}","branches_url":"https://api.github.com/repos/antonkoh/questionanswer/branches{/branch}","tags_url":"https://api.github.com/repos/antonkoh/questionanswer/tags","blobs_url":"https://api.github.com/repos/antonkoh/questionanswer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antonkoh/questionanswer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antonkoh/questionanswer/git/refs{/sha}","trees_url":"https://api.github.com/repos/antonkoh/questionanswer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antonkoh/questionanswer/statuses/{sha}","languages_url":"https://api.github.com/repos/antonkoh/questionanswer/languages","stargazers_url":"https://api.github.com/repos/antonkoh/questionanswer/stargazers","contributors_url":"https://api.github.com/repos/antonkoh/questionanswer/contributors","subscribers_url":"https://api.github.com/repos/antonkoh/questionanswer/subscribers","subscription_url":"https://api.github.com/repos/antonkoh/questionanswer/subscription","commits_url":"https://api.github.com/repos/antonkoh/questionanswer/commits{/sha}","git_commits_url":"https://api.github.com/repos/antonkoh/questionanswer/git/commits{/sha}","comments_url":"https://api.github.com/repos/antonkoh/questionanswer/comments{/number}","issue_comment_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/comments{/number}","contents_url":"https://api.github.com/repos/antonkoh/questionanswer/contents/{+path}","compare_url":"https://api.github.com/repos/antonkoh/questionanswer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antonkoh/questionanswer/merges","archive_url":"https://api.github.com/repos/antonkoh/questionanswer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antonkoh/questionanswer/downloads","issues_url":"https://api.github.com/repos/antonkoh/questionanswer/issues{/number}","pulls_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls{/number}","milestones_url":"https://api.github.com/repos/antonkoh/questionanswer/milestones{/number}","notifications_url":"https://api.github.com/repos/antonkoh/questionanswer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antonkoh/questionanswer/labels{/name}","releases_url":"https://api.github.com/repos/antonkoh/questionanswer/releases{/id}","deployments_url":"https://api.github.com/repos/antonkoh/questionanswer/deployments","created_at":"2016-01-23T21:25:14Z","updated_at":"2016-01-23T22:02:04Z","pushed_at":"2016-02-07T18:16:28Z","git_url":"git://github.com/antonkoh/questionanswer.git","ssh_url":"git@github.com:antonkoh/questionanswer.git","clone_url":"https://github.com/antonkoh/questionanswer.git","svn_url":"https://github.com/antonkoh/questionanswer","homepage":null,"size":139,"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":23,"forks":0,"open_issues":23,"watchers":0,"default_branch":"master"}},"base":{"label":"antonkoh:master","ref":"master","sha":"bb967bda72a491c1507e868364408b178db92c85","user":{"login":"antonkoh","id":14329340,"avatar_url":"https://avatars.githubusercontent.com/u/14329340?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkoh","html_url":"https://github.com/antonkoh","followers_url":"https://api.github.com/users/antonkoh/followers","following_url":"https://api.github.com/users/antonkoh/following{/other_user}","gists_url":"https://api.github.com/users/antonkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkoh/subscriptions","organizations_url":"https://api.github.com/users/antonkoh/orgs","repos_url":"https://api.github.com/users/antonkoh/repos","events_url":"https://api.github.com/users/antonkoh/events{/privacy}","received_events_url":"https://api.github.com/users/antonkoh/received_events","type":"User","site_admin":false},"repo":{"id":50259189,"name":"questionanswer","full_name":"antonkoh/questionanswer","owner":{"login":"antonkoh","id":14329340,"avatar_url":"https://avatars.githubusercontent.com/u/14329340?v=3","gravatar_id":"","url":"https://api.github.com/users/antonkoh","html_url":"https://github.com/antonkoh","followers_url":"https://api.github.com/users/antonkoh/followers","following_url":"https://api.github.com/users/antonkoh/following{/other_user}","gists_url":"https://api.github.com/users/antonkoh/gists{/gist_id}","starred_url":"https://api.github.com/users/antonkoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antonkoh/subscriptions","organizations_url":"https://api.github.com/users/antonkoh/orgs","repos_url":"https://api.github.com/users/antonkoh/repos","events_url":"https://api.github.com/users/antonkoh/events{/privacy}","received_events_url":"https://api.github.com/users/antonkoh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/antonkoh/questionanswer","description":"","fork":false,"url":"https://api.github.com/repos/antonkoh/questionanswer","forks_url":"https://api.github.com/repos/antonkoh/questionanswer/forks","keys_url":"https://api.github.com/repos/antonkoh/questionanswer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/antonkoh/questionanswer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/antonkoh/questionanswer/teams","hooks_url":"https://api.github.com/repos/antonkoh/questionanswer/hooks","issue_events_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/events{/number}","events_url":"https://api.github.com/repos/antonkoh/questionanswer/events","assignees_url":"https://api.github.com/repos/antonkoh/questionanswer/assignees{/user}","branches_url":"https://api.github.com/repos/antonkoh/questionanswer/branches{/branch}","tags_url":"https://api.github.com/repos/antonkoh/questionanswer/tags","blobs_url":"https://api.github.com/repos/antonkoh/questionanswer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/antonkoh/questionanswer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/antonkoh/questionanswer/git/refs{/sha}","trees_url":"https://api.github.com/repos/antonkoh/questionanswer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/antonkoh/questionanswer/statuses/{sha}","languages_url":"https://api.github.com/repos/antonkoh/questionanswer/languages","stargazers_url":"https://api.github.com/repos/antonkoh/questionanswer/stargazers","contributors_url":"https://api.github.com/repos/antonkoh/questionanswer/contributors","subscribers_url":"https://api.github.com/repos/antonkoh/questionanswer/subscribers","subscription_url":"https://api.github.com/repos/antonkoh/questionanswer/subscription","commits_url":"https://api.github.com/repos/antonkoh/questionanswer/commits{/sha}","git_commits_url":"https://api.github.com/repos/antonkoh/questionanswer/git/commits{/sha}","comments_url":"https://api.github.com/repos/antonkoh/questionanswer/comments{/number}","issue_comment_url":"https://api.github.com/repos/antonkoh/questionanswer/issues/comments{/number}","contents_url":"https://api.github.com/repos/antonkoh/questionanswer/contents/{+path}","compare_url":"https://api.github.com/repos/antonkoh/questionanswer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/antonkoh/questionanswer/merges","archive_url":"https://api.github.com/repos/antonkoh/questionanswer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/antonkoh/questionanswer/downloads","issues_url":"https://api.github.com/repos/antonkoh/questionanswer/issues{/number}","pulls_url":"https://api.github.com/repos/antonkoh/questionanswer/pulls{/number}","milestones_url":"https://api.github.com/repos/antonkoh/questionanswer/milestones{/number}","notifications_url":"https://api.github.com/repos/antonkoh/questionanswer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/antonkoh/questionanswer/labels{/name}","releases_url":"https://api.github.com/repos/antonkoh/questionanswer/releases{/id}","deployments_url":"https://api.github.com/repos/antonkoh/questionanswer/deployments","created_at":"2016-01-23T21:25:14Z","updated_at":"2016-01-23T22:02:04Z","pushed_at":"2016-02-07T18:16:28Z","git_url":"git://github.com/antonkoh/questionanswer.git","ssh_url":"git@github.com:antonkoh/questionanswer.git","clone_url":"https://github.com/antonkoh/questionanswer.git","svn_url":"https://github.com/antonkoh/questionanswer","homepage":null,"size":139,"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":23,"forks":0,"open_issues":23,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20"},"html":{"href":"https://github.com/antonkoh/questionanswer/pull/20"},"issue":{"href":"https://api.github.com/repos/antonkoh/questionanswer/issues/20"},"comments":{"href":"https://api.github.com/repos/antonkoh/questionanswer/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/antonkoh/questionanswer/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/antonkoh/questionanswer/statuses/255075d3b0153b41968c08bfa31033a95f0c197b"}}}}