{"action":"created","comment":{"url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/comments/45958647","id":45958647,"diff_hunk":"@@ -15,24 +12,35 @@ def edit\n \n   def create\n     @answer = @question.answers.new(answer_params)\n+    @answer.user = current_user\n+\n     if @answer.save\n-      redirect_to @question\n+      redirect_to @answer.question\n     else\n+      flash.now[:notice] = 'Please, enter the correct data!'\n       render :new\n     end\n   end\n \n   def update\n-    if @answer.update(answer_params)\n-      redirect_to @question\n+    if current_user.author_of?(@answer)\n+      if @answer.update(answer_params)\n+        redirect_to @answer.question, notice: 'Your answer is saved!'\n+      else\n+        render :edit\n+      end\n     else\n-      render :edit\n+      redirect_to @answer.question, notice: 'You is not owner of this answer!'\n     end\n   end\n \n   def destroy\n-    @answer.destroy\n-    redirect_to @question\n+    if @answer.user_id == current_user.id","path":"app/controllers/answers_controller.rb","position":47,"original_position":47,"commit_id":"55716dddd0b5546959020d5d205cfbcde9d1d7e8","original_commit_id":"55716dddd0b5546959020d5d205cfbcde9d1d7e8","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":"Ну а чего здесь не заменил на author_of? Нужно все такие проверки, в т.ч. в видах заменить на метод author_of?","created_at":"2015-11-26T09:38:01Z","updated_at":"2015-11-26T09:38:01Z","html_url":"https://github.com/MihailSergeenkov/answer_me/pull/3#discussion_r45958647","pull_request_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/comments/45958647"},"html":{"href":"https://github.com/MihailSergeenkov/answer_me/pull/3#discussion_r45958647"},"pull_request":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3","id":51450926,"html_url":"https://github.com/MihailSergeenkov/answer_me/pull/3","diff_url":"https://github.com/MihailSergeenkov/answer_me/pull/3.diff","patch_url":"https://github.com/MihailSergeenkov/answer_me/pull/3.patch","issue_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/3","number":3,"state":"open","locked":false,"title":"Lesson 5","user":{"login":"MihailSergeenkov","id":10576643,"avatar_url":"https://avatars.githubusercontent.com/u/10576643?v=3","gravatar_id":"","url":"https://api.github.com/users/MihailSergeenkov","html_url":"https://github.com/MihailSergeenkov","followers_url":"https://api.github.com/users/MihailSergeenkov/followers","following_url":"https://api.github.com/users/MihailSergeenkov/following{/other_user}","gists_url":"https://api.github.com/users/MihailSergeenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/MihailSergeenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MihailSergeenkov/subscriptions","organizations_url":"https://api.github.com/users/MihailSergeenkov/orgs","repos_url":"https://api.github.com/users/MihailSergeenkov/repos","events_url":"https://api.github.com/users/MihailSergeenkov/events{/privacy}","received_events_url":"https://api.github.com/users/MihailSergeenkov/received_events","type":"User","site_admin":false},"body":"Реализовать следующие истории, начиная с acceptance-тестов (если они уже реализованы, покрыть acceptance-тестами):\r\n- Пользователь может создавать вопрос\r\n- Пользователь может просматривать список вопросов\r\n- Пользователь может написать ответ на вопрос\r\n- Пользователь может просматривать вопрос и ответы к нему.\r\nДобавить аутентификацию к проекту, покрыть acceptance-тестами следующие сценарии:\r\n- Пользователь может войти в систему\r\n- Пользователь может выйти из системы\r\n- Пользователь может зарегистрироваться в системе\r\nРеализовать следующие истории:\r\n- Только аутентифицированный пользователь может создавать вопросы и ответы\r\n- Автор может удалить свой вопрос или ответ, но не может удалить чужой вопрос/ответ","created_at":"2015-11-21T21:38:43Z","updated_at":"2015-11-26T09:38:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3151a745ecc41e818395af7c3f1a494b3225119","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3/commits","review_comments_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3/comments","review_comment_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/3/comments","statuses_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/statuses/55716dddd0b5546959020d5d205cfbcde9d1d7e8","head":{"label":"MihailSergeenkov:lesson_5","ref":"lesson_5","sha":"55716dddd0b5546959020d5d205cfbcde9d1d7e8","user":{"login":"MihailSergeenkov","id":10576643,"avatar_url":"https://avatars.githubusercontent.com/u/10576643?v=3","gravatar_id":"","url":"https://api.github.com/users/MihailSergeenkov","html_url":"https://github.com/MihailSergeenkov","followers_url":"https://api.github.com/users/MihailSergeenkov/followers","following_url":"https://api.github.com/users/MihailSergeenkov/following{/other_user}","gists_url":"https://api.github.com/users/MihailSergeenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/MihailSergeenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MihailSergeenkov/subscriptions","organizations_url":"https://api.github.com/users/MihailSergeenkov/orgs","repos_url":"https://api.github.com/users/MihailSergeenkov/repos","events_url":"https://api.github.com/users/MihailSergeenkov/events{/privacy}","received_events_url":"https://api.github.com/users/MihailSergeenkov/received_events","type":"User","site_admin":false},"repo":{"id":45789392,"name":"answer_me","full_name":"MihailSergeenkov/answer_me","owner":{"login":"MihailSergeenkov","id":10576643,"avatar_url":"https://avatars.githubusercontent.com/u/10576643?v=3","gravatar_id":"","url":"https://api.github.com/users/MihailSergeenkov","html_url":"https://github.com/MihailSergeenkov","followers_url":"https://api.github.com/users/MihailSergeenkov/followers","following_url":"https://api.github.com/users/MihailSergeenkov/following{/other_user}","gists_url":"https://api.github.com/users/MihailSergeenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/MihailSergeenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MihailSergeenkov/subscriptions","organizations_url":"https://api.github.com/users/MihailSergeenkov/orgs","repos_url":"https://api.github.com/users/MihailSergeenkov/repos","events_url":"https://api.github.com/users/MihailSergeenkov/events{/privacy}","received_events_url":"https://api.github.com/users/MihailSergeenkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MihailSergeenkov/answer_me","description":"","fork":false,"url":"https://api.github.com/repos/MihailSergeenkov/answer_me","forks_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/forks","keys_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/teams","hooks_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/hooks","issue_events_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/events{/number}","events_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/events","assignees_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/assignees{/user}","branches_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/branches{/branch}","tags_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/tags","blobs_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/refs{/sha}","trees_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/statuses/{sha}","languages_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/languages","stargazers_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/stargazers","contributors_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/contributors","subscribers_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/subscribers","subscription_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/subscription","commits_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/commits{/sha}","git_commits_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/commits{/sha}","comments_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/comments{/number}","issue_comment_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/comments{/number}","contents_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/contents/{+path}","compare_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/merges","archive_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/downloads","issues_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues{/number}","pulls_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls{/number}","milestones_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/milestones{/number}","notifications_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/labels{/name}","releases_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/releases{/id}","created_at":"2015-11-08T16:52:21Z","updated_at":"2015-11-08T17:13:07Z","pushed_at":"2015-11-25T21:17:30Z","git_url":"git://github.com/MihailSergeenkov/answer_me.git","ssh_url":"git@github.com:MihailSergeenkov/answer_me.git","clone_url":"https://github.com/MihailSergeenkov/answer_me.git","svn_url":"https://github.com/MihailSergeenkov/answer_me","homepage":null,"size":76,"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":"MihailSergeenkov:master","ref":"master","sha":"f36ae32dcfec6502132aad92c43d30963e656c8b","user":{"login":"MihailSergeenkov","id":10576643,"avatar_url":"https://avatars.githubusercontent.com/u/10576643?v=3","gravatar_id":"","url":"https://api.github.com/users/MihailSergeenkov","html_url":"https://github.com/MihailSergeenkov","followers_url":"https://api.github.com/users/MihailSergeenkov/followers","following_url":"https://api.github.com/users/MihailSergeenkov/following{/other_user}","gists_url":"https://api.github.com/users/MihailSergeenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/MihailSergeenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MihailSergeenkov/subscriptions","organizations_url":"https://api.github.com/users/MihailSergeenkov/orgs","repos_url":"https://api.github.com/users/MihailSergeenkov/repos","events_url":"https://api.github.com/users/MihailSergeenkov/events{/privacy}","received_events_url":"https://api.github.com/users/MihailSergeenkov/received_events","type":"User","site_admin":false},"repo":{"id":45789392,"name":"answer_me","full_name":"MihailSergeenkov/answer_me","owner":{"login":"MihailSergeenkov","id":10576643,"avatar_url":"https://avatars.githubusercontent.com/u/10576643?v=3","gravatar_id":"","url":"https://api.github.com/users/MihailSergeenkov","html_url":"https://github.com/MihailSergeenkov","followers_url":"https://api.github.com/users/MihailSergeenkov/followers","following_url":"https://api.github.com/users/MihailSergeenkov/following{/other_user}","gists_url":"https://api.github.com/users/MihailSergeenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/MihailSergeenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MihailSergeenkov/subscriptions","organizations_url":"https://api.github.com/users/MihailSergeenkov/orgs","repos_url":"https://api.github.com/users/MihailSergeenkov/repos","events_url":"https://api.github.com/users/MihailSergeenkov/events{/privacy}","received_events_url":"https://api.github.com/users/MihailSergeenkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MihailSergeenkov/answer_me","description":"","fork":false,"url":"https://api.github.com/repos/MihailSergeenkov/answer_me","forks_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/forks","keys_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/teams","hooks_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/hooks","issue_events_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/events{/number}","events_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/events","assignees_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/assignees{/user}","branches_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/branches{/branch}","tags_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/tags","blobs_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/refs{/sha}","trees_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/statuses/{sha}","languages_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/languages","stargazers_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/stargazers","contributors_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/contributors","subscribers_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/subscribers","subscription_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/subscription","commits_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/commits{/sha}","git_commits_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/git/commits{/sha}","comments_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/comments{/number}","issue_comment_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/comments{/number}","contents_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/contents/{+path}","compare_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/merges","archive_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/downloads","issues_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues{/number}","pulls_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls{/number}","milestones_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/milestones{/number}","notifications_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/labels{/name}","releases_url":"https://api.github.com/repos/MihailSergeenkov/answer_me/releases{/id}","created_at":"2015-11-08T16:52:21Z","updated_at":"2015-11-08T17:13:07Z","pushed_at":"2015-11-25T21:17:30Z","git_url":"git://github.com/MihailSergeenkov/answer_me.git","ssh_url":"git@github.com:MihailSergeenkov/answer_me.git","clone_url":"https://github.com/MihailSergeenkov/answer_me.git","svn_url":"https://github.com/MihailSergeenkov/answer_me","homepage":null,"size":76,"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/MihailSergeenkov/answer_me/pulls/3"},"html":{"href":"https://github.com/MihailSergeenkov/answer_me/pull/3"},"issue":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/3"},"comments":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/MihailSergeenkov/answer_me/statuses/55716dddd0b5546959020d5d205cfbcde9d1d7e8"}}}}