{"action":"created","comment":{"url":"https://api.github.com/repos/one0fnine/QnA/pulls/comments/63332765","id":63332765,"diff_hunk":"@@ -9,12 +10,29 @@ def create\n   end\n \n   def destroy\n-    @answer = Answer.find(params[:id])\n     @answer.destroy if current_user.author_of?(@answer)\n   end\n \n+  def edit; end\n+\n+  def update\n+    @answer.update(answer_params) if current_user.author_of?(@answer)\n+  end\n+\n+  def is_best!\n+    @question.answers.update_all(best: false)","path":"app/controllers/answers_controller.rb","position":24,"original_position":24,"commit_id":"f3c2700fe2dc110efe1153dd607f947716b9ff37","original_commit_id":"f3c2700fe2dc110efe1153dd607f947716b9ff37","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":"Эта логика должна быть в методе модели Answer, а тут только вызывается этот метод. И еще эту логику надо в транзакцию обернуть, чтобы изменения были атомарными. И проверять на автора надо ДО того, как вносятся изменения, причем, проверка как раз в контроллере должна быть","created_at":"2016-05-16T10:04:43Z","updated_at":"2016-05-16T10:04:43Z","html_url":"https://github.com/one0fnine/QnA/pull/5#discussion_r63332765","pull_request_url":"https://api.github.com/repos/one0fnine/QnA/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/one0fnine/QnA/pulls/comments/63332765"},"html":{"href":"https://github.com/one0fnine/QnA/pull/5#discussion_r63332765"},"pull_request":{"href":"https://api.github.com/repos/one0fnine/QnA/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/one0fnine/QnA/pulls/5","id":70171589,"html_url":"https://github.com/one0fnine/QnA/pull/5","diff_url":"https://github.com/one0fnine/QnA/pull/5.diff","patch_url":"https://github.com/one0fnine/QnA/pull/5.patch","issue_url":"https://api.github.com/repos/one0fnine/QnA/issues/5","number":5,"state":"open","locked":false,"title":"Feature/ajax edit answers","user":{"login":"one0fnine","id":7098834,"avatar_url":"https://avatars.githubusercontent.com/u/7098834?v=3","gravatar_id":"","url":"https://api.github.com/users/one0fnine","html_url":"https://github.com/one0fnine","followers_url":"https://api.github.com/users/one0fnine/followers","following_url":"https://api.github.com/users/one0fnine/following{/other_user}","gists_url":"https://api.github.com/users/one0fnine/gists{/gist_id}","starred_url":"https://api.github.com/users/one0fnine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one0fnine/subscriptions","organizations_url":"https://api.github.com/users/one0fnine/orgs","repos_url":"https://api.github.com/users/one0fnine/repos","events_url":"https://api.github.com/users/one0fnine/events{/privacy}","received_events_url":"https://api.github.com/users/one0fnine/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-16T09:32:41Z","updated_at":"2016-05-16T10:04:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"556b92399096800a00229dd63a7bef7f065710d8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/one0fnine/QnA/pulls/5/commits","review_comments_url":"https://api.github.com/repos/one0fnine/QnA/pulls/5/comments","review_comment_url":"https://api.github.com/repos/one0fnine/QnA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/one0fnine/QnA/issues/5/comments","statuses_url":"https://api.github.com/repos/one0fnine/QnA/statuses/f3c2700fe2dc110efe1153dd607f947716b9ff37","head":{"label":"one0fnine:feature/ajax_edit_answers","ref":"feature/ajax_edit_answers","sha":"f3c2700fe2dc110efe1153dd607f947716b9ff37","user":{"login":"one0fnine","id":7098834,"avatar_url":"https://avatars.githubusercontent.com/u/7098834?v=3","gravatar_id":"","url":"https://api.github.com/users/one0fnine","html_url":"https://github.com/one0fnine","followers_url":"https://api.github.com/users/one0fnine/followers","following_url":"https://api.github.com/users/one0fnine/following{/other_user}","gists_url":"https://api.github.com/users/one0fnine/gists{/gist_id}","starred_url":"https://api.github.com/users/one0fnine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one0fnine/subscriptions","organizations_url":"https://api.github.com/users/one0fnine/orgs","repos_url":"https://api.github.com/users/one0fnine/repos","events_url":"https://api.github.com/users/one0fnine/events{/privacy}","received_events_url":"https://api.github.com/users/one0fnine/received_events","type":"User","site_admin":false},"repo":{"id":57035511,"name":"QnA","full_name":"one0fnine/QnA","owner":{"login":"one0fnine","id":7098834,"avatar_url":"https://avatars.githubusercontent.com/u/7098834?v=3","gravatar_id":"","url":"https://api.github.com/users/one0fnine","html_url":"https://github.com/one0fnine","followers_url":"https://api.github.com/users/one0fnine/followers","following_url":"https://api.github.com/users/one0fnine/following{/other_user}","gists_url":"https://api.github.com/users/one0fnine/gists{/gist_id}","starred_url":"https://api.github.com/users/one0fnine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one0fnine/subscriptions","organizations_url":"https://api.github.com/users/one0fnine/orgs","repos_url":"https://api.github.com/users/one0fnine/repos","events_url":"https://api.github.com/users/one0fnine/events{/privacy}","received_events_url":"https://api.github.com/users/one0fnine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/one0fnine/QnA","description":"","fork":false,"url":"https://api.github.com/repos/one0fnine/QnA","forks_url":"https://api.github.com/repos/one0fnine/QnA/forks","keys_url":"https://api.github.com/repos/one0fnine/QnA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/one0fnine/QnA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/one0fnine/QnA/teams","hooks_url":"https://api.github.com/repos/one0fnine/QnA/hooks","issue_events_url":"https://api.github.com/repos/one0fnine/QnA/issues/events{/number}","events_url":"https://api.github.com/repos/one0fnine/QnA/events","assignees_url":"https://api.github.com/repos/one0fnine/QnA/assignees{/user}","branches_url":"https://api.github.com/repos/one0fnine/QnA/branches{/branch}","tags_url":"https://api.github.com/repos/one0fnine/QnA/tags","blobs_url":"https://api.github.com/repos/one0fnine/QnA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/one0fnine/QnA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/one0fnine/QnA/git/refs{/sha}","trees_url":"https://api.github.com/repos/one0fnine/QnA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/one0fnine/QnA/statuses/{sha}","languages_url":"https://api.github.com/repos/one0fnine/QnA/languages","stargazers_url":"https://api.github.com/repos/one0fnine/QnA/stargazers","contributors_url":"https://api.github.com/repos/one0fnine/QnA/contributors","subscribers_url":"https://api.github.com/repos/one0fnine/QnA/subscribers","subscription_url":"https://api.github.com/repos/one0fnine/QnA/subscription","commits_url":"https://api.github.com/repos/one0fnine/QnA/commits{/sha}","git_commits_url":"https://api.github.com/repos/one0fnine/QnA/git/commits{/sha}","comments_url":"https://api.github.com/repos/one0fnine/QnA/comments{/number}","issue_comment_url":"https://api.github.com/repos/one0fnine/QnA/issues/comments{/number}","contents_url":"https://api.github.com/repos/one0fnine/QnA/contents/{+path}","compare_url":"https://api.github.com/repos/one0fnine/QnA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/one0fnine/QnA/merges","archive_url":"https://api.github.com/repos/one0fnine/QnA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/one0fnine/QnA/downloads","issues_url":"https://api.github.com/repos/one0fnine/QnA/issues{/number}","pulls_url":"https://api.github.com/repos/one0fnine/QnA/pulls{/number}","milestones_url":"https://api.github.com/repos/one0fnine/QnA/milestones{/number}","notifications_url":"https://api.github.com/repos/one0fnine/QnA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/one0fnine/QnA/labels{/name}","releases_url":"https://api.github.com/repos/one0fnine/QnA/releases{/id}","deployments_url":"https://api.github.com/repos/one0fnine/QnA/deployments","created_at":"2016-04-25T11:12:18Z","updated_at":"2016-04-25T11:25:02Z","pushed_at":"2016-05-16T09:32:42Z","git_url":"git://github.com/one0fnine/QnA.git","ssh_url":"git@github.com:one0fnine/QnA.git","clone_url":"https://github.com/one0fnine/QnA.git","svn_url":"https://github.com/one0fnine/QnA","homepage":null,"size":113,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"one0fnine:master","ref":"master","sha":"4833d32086c69efa62bfbabc6b793332ed0e1d2e","user":{"login":"one0fnine","id":7098834,"avatar_url":"https://avatars.githubusercontent.com/u/7098834?v=3","gravatar_id":"","url":"https://api.github.com/users/one0fnine","html_url":"https://github.com/one0fnine","followers_url":"https://api.github.com/users/one0fnine/followers","following_url":"https://api.github.com/users/one0fnine/following{/other_user}","gists_url":"https://api.github.com/users/one0fnine/gists{/gist_id}","starred_url":"https://api.github.com/users/one0fnine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one0fnine/subscriptions","organizations_url":"https://api.github.com/users/one0fnine/orgs","repos_url":"https://api.github.com/users/one0fnine/repos","events_url":"https://api.github.com/users/one0fnine/events{/privacy}","received_events_url":"https://api.github.com/users/one0fnine/received_events","type":"User","site_admin":false},"repo":{"id":57035511,"name":"QnA","full_name":"one0fnine/QnA","owner":{"login":"one0fnine","id":7098834,"avatar_url":"https://avatars.githubusercontent.com/u/7098834?v=3","gravatar_id":"","url":"https://api.github.com/users/one0fnine","html_url":"https://github.com/one0fnine","followers_url":"https://api.github.com/users/one0fnine/followers","following_url":"https://api.github.com/users/one0fnine/following{/other_user}","gists_url":"https://api.github.com/users/one0fnine/gists{/gist_id}","starred_url":"https://api.github.com/users/one0fnine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one0fnine/subscriptions","organizations_url":"https://api.github.com/users/one0fnine/orgs","repos_url":"https://api.github.com/users/one0fnine/repos","events_url":"https://api.github.com/users/one0fnine/events{/privacy}","received_events_url":"https://api.github.com/users/one0fnine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/one0fnine/QnA","description":"","fork":false,"url":"https://api.github.com/repos/one0fnine/QnA","forks_url":"https://api.github.com/repos/one0fnine/QnA/forks","keys_url":"https://api.github.com/repos/one0fnine/QnA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/one0fnine/QnA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/one0fnine/QnA/teams","hooks_url":"https://api.github.com/repos/one0fnine/QnA/hooks","issue_events_url":"https://api.github.com/repos/one0fnine/QnA/issues/events{/number}","events_url":"https://api.github.com/repos/one0fnine/QnA/events","assignees_url":"https://api.github.com/repos/one0fnine/QnA/assignees{/user}","branches_url":"https://api.github.com/repos/one0fnine/QnA/branches{/branch}","tags_url":"https://api.github.com/repos/one0fnine/QnA/tags","blobs_url":"https://api.github.com/repos/one0fnine/QnA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/one0fnine/QnA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/one0fnine/QnA/git/refs{/sha}","trees_url":"https://api.github.com/repos/one0fnine/QnA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/one0fnine/QnA/statuses/{sha}","languages_url":"https://api.github.com/repos/one0fnine/QnA/languages","stargazers_url":"https://api.github.com/repos/one0fnine/QnA/stargazers","contributors_url":"https://api.github.com/repos/one0fnine/QnA/contributors","subscribers_url":"https://api.github.com/repos/one0fnine/QnA/subscribers","subscription_url":"https://api.github.com/repos/one0fnine/QnA/subscription","commits_url":"https://api.github.com/repos/one0fnine/QnA/commits{/sha}","git_commits_url":"https://api.github.com/repos/one0fnine/QnA/git/commits{/sha}","comments_url":"https://api.github.com/repos/one0fnine/QnA/comments{/number}","issue_comment_url":"https://api.github.com/repos/one0fnine/QnA/issues/comments{/number}","contents_url":"https://api.github.com/repos/one0fnine/QnA/contents/{+path}","compare_url":"https://api.github.com/repos/one0fnine/QnA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/one0fnine/QnA/merges","archive_url":"https://api.github.com/repos/one0fnine/QnA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/one0fnine/QnA/downloads","issues_url":"https://api.github.com/repos/one0fnine/QnA/issues{/number}","pulls_url":"https://api.github.com/repos/one0fnine/QnA/pulls{/number}","milestones_url":"https://api.github.com/repos/one0fnine/QnA/milestones{/number}","notifications_url":"https://api.github.com/repos/one0fnine/QnA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/one0fnine/QnA/labels{/name}","releases_url":"https://api.github.com/repos/one0fnine/QnA/releases{/id}","deployments_url":"https://api.github.com/repos/one0fnine/QnA/deployments","created_at":"2016-04-25T11:12:18Z","updated_at":"2016-04-25T11:25:02Z","pushed_at":"2016-05-16T09:32:42Z","git_url":"git://github.com/one0fnine/QnA.git","ssh_url":"git@github.com:one0fnine/QnA.git","clone_url":"https://github.com/one0fnine/QnA.git","svn_url":"https://github.com/one0fnine/QnA","homepage":null,"size":113,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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/one0fnine/QnA/pulls/5"},"html":{"href":"https://github.com/one0fnine/QnA/pull/5"},"issue":{"href":"https://api.github.com/repos/one0fnine/QnA/issues/5"},"comments":{"href":"https://api.github.com/repos/one0fnine/QnA/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/one0fnine/QnA/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/one0fnine/QnA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/one0fnine/QnA/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/one0fnine/QnA/statuses/f3c2700fe2dc110efe1153dd607f947716b9ff37"}}}}