{"action":"created","comment":{"url":"https://api.github.com/repos/alteregoizm/qna/pulls/comments/59965751","id":59965751,"diff_hunk":"@@ -9,33 +10,31 @@ def index\n   def show\n   end\n \n-  def new\n-    @answer = @question.answers.new\n-  end\n-\n   def edit\n   end\n \n   def create\n-    @answer = @question.answers.new(answer_params)\n-    if @answer.save\n-      redirect_to @question\n-    else\n-      render :new\n-    end\n+    @answer = @question.answers.new(answer_params.merge({ user: current_user }))\n+    flash[:error] = 'Invalid answer' unless @answer.save\n+    redirect_to @question","path":"app/controllers/answers_controller.rb","position":26,"original_position":26,"commit_id":"d55d027595bffba88da5f192c1e011c72f27666f","original_commit_id":"a438f72dbffe20b039d60e845bc59f02a6432a01","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":"Ситуация: пользователь вводил длинный ответ, нажал сохранить, оказалось, скажем, что он превысил максимальное кол-во символов в ответе. Мы ему показываем \"Invalid answer\", при этом не объясняя, в чем проблема, это раз, и показываем ему пустое поле без того текста, который он вводил. Это два. Как ты думаешь, пользователь будет рад такому поведению?\r\nПоэтому ошибки валидации надо выводить полностью и сохранять то, что ввел пользователь, чтобы он мог это исправить. А для этого нужен render, т.к. при редиректе все, что он ввел потеряется.","created_at":"2016-04-16T10:41:15Z","updated_at":"2016-04-16T10:41:15Z","html_url":"https://github.com/alteregoizm/qna/pull/3#discussion_r59965751","pull_request_url":"https://api.github.com/repos/alteregoizm/qna/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/alteregoizm/qna/pulls/comments/59965751"},"html":{"href":"https://github.com/alteregoizm/qna/pull/3#discussion_r59965751"},"pull_request":{"href":"https://api.github.com/repos/alteregoizm/qna/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/alteregoizm/qna/pulls/3","id":66340375,"html_url":"https://github.com/alteregoizm/qna/pull/3","diff_url":"https://github.com/alteregoizm/qna/pull/3.diff","patch_url":"https://github.com/alteregoizm/qna/pull/3.patch","issue_url":"https://api.github.com/repos/alteregoizm/qna/issues/3","number":3,"state":"open","locked":false,"title":"Lesson5","user":{"login":"alteregoizm","id":11354098,"avatar_url":"https://avatars.githubusercontent.com/u/11354098?v=3","gravatar_id":"","url":"https://api.github.com/users/alteregoizm","html_url":"https://github.com/alteregoizm","followers_url":"https://api.github.com/users/alteregoizm/followers","following_url":"https://api.github.com/users/alteregoizm/following{/other_user}","gists_url":"https://api.github.com/users/alteregoizm/gists{/gist_id}","starred_url":"https://api.github.com/users/alteregoizm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteregoizm/subscriptions","organizations_url":"https://api.github.com/users/alteregoizm/orgs","repos_url":"https://api.github.com/users/alteregoizm/repos","events_url":"https://api.github.com/users/alteregoizm/events{/privacy}","received_events_url":"https://api.github.com/users/alteregoizm/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T15:22:49Z","updated_at":"2016-04-16T10:41:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"159d131ed2196c3e6adbec7d88815ce618ceecdd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alteregoizm/qna/pulls/3/commits","review_comments_url":"https://api.github.com/repos/alteregoizm/qna/pulls/3/comments","review_comment_url":"https://api.github.com/repos/alteregoizm/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alteregoizm/qna/issues/3/comments","statuses_url":"https://api.github.com/repos/alteregoizm/qna/statuses/d55d027595bffba88da5f192c1e011c72f27666f","head":{"label":"alteregoizm:Lesson5","ref":"Lesson5","sha":"d55d027595bffba88da5f192c1e011c72f27666f","user":{"login":"alteregoizm","id":11354098,"avatar_url":"https://avatars.githubusercontent.com/u/11354098?v=3","gravatar_id":"","url":"https://api.github.com/users/alteregoizm","html_url":"https://github.com/alteregoizm","followers_url":"https://api.github.com/users/alteregoizm/followers","following_url":"https://api.github.com/users/alteregoizm/following{/other_user}","gists_url":"https://api.github.com/users/alteregoizm/gists{/gist_id}","starred_url":"https://api.github.com/users/alteregoizm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteregoizm/subscriptions","organizations_url":"https://api.github.com/users/alteregoizm/orgs","repos_url":"https://api.github.com/users/alteregoizm/repos","events_url":"https://api.github.com/users/alteregoizm/events{/privacy}","received_events_url":"https://api.github.com/users/alteregoizm/received_events","type":"User","site_admin":false},"repo":{"id":54586382,"name":"qna","full_name":"alteregoizm/qna","owner":{"login":"alteregoizm","id":11354098,"avatar_url":"https://avatars.githubusercontent.com/u/11354098?v=3","gravatar_id":"","url":"https://api.github.com/users/alteregoizm","html_url":"https://github.com/alteregoizm","followers_url":"https://api.github.com/users/alteregoizm/followers","following_url":"https://api.github.com/users/alteregoizm/following{/other_user}","gists_url":"https://api.github.com/users/alteregoizm/gists{/gist_id}","starred_url":"https://api.github.com/users/alteregoizm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteregoizm/subscriptions","organizations_url":"https://api.github.com/users/alteregoizm/orgs","repos_url":"https://api.github.com/users/alteregoizm/repos","events_url":"https://api.github.com/users/alteregoizm/events{/privacy}","received_events_url":"https://api.github.com/users/alteregoizm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alteregoizm/qna","description":"","fork":false,"url":"https://api.github.com/repos/alteregoizm/qna","forks_url":"https://api.github.com/repos/alteregoizm/qna/forks","keys_url":"https://api.github.com/repos/alteregoizm/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alteregoizm/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alteregoizm/qna/teams","hooks_url":"https://api.github.com/repos/alteregoizm/qna/hooks","issue_events_url":"https://api.github.com/repos/alteregoizm/qna/issues/events{/number}","events_url":"https://api.github.com/repos/alteregoizm/qna/events","assignees_url":"https://api.github.com/repos/alteregoizm/qna/assignees{/user}","branches_url":"https://api.github.com/repos/alteregoizm/qna/branches{/branch}","tags_url":"https://api.github.com/repos/alteregoizm/qna/tags","blobs_url":"https://api.github.com/repos/alteregoizm/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alteregoizm/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alteregoizm/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/alteregoizm/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alteregoizm/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/alteregoizm/qna/languages","stargazers_url":"https://api.github.com/repos/alteregoizm/qna/stargazers","contributors_url":"https://api.github.com/repos/alteregoizm/qna/contributors","subscribers_url":"https://api.github.com/repos/alteregoizm/qna/subscribers","subscription_url":"https://api.github.com/repos/alteregoizm/qna/subscription","commits_url":"https://api.github.com/repos/alteregoizm/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/alteregoizm/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/alteregoizm/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/alteregoizm/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/alteregoizm/qna/contents/{+path}","compare_url":"https://api.github.com/repos/alteregoizm/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alteregoizm/qna/merges","archive_url":"https://api.github.com/repos/alteregoizm/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alteregoizm/qna/downloads","issues_url":"https://api.github.com/repos/alteregoizm/qna/issues{/number}","pulls_url":"https://api.github.com/repos/alteregoizm/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/alteregoizm/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/alteregoizm/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alteregoizm/qna/labels{/name}","releases_url":"https://api.github.com/repos/alteregoizm/qna/releases{/id}","deployments_url":"https://api.github.com/repos/alteregoizm/qna/deployments","created_at":"2016-03-23T19:11:48Z","updated_at":"2016-03-23T19:11:53Z","pushed_at":"2016-04-15T14:00:48Z","git_url":"git://github.com/alteregoizm/qna.git","ssh_url":"git@github.com:alteregoizm/qna.git","clone_url":"https://github.com/alteregoizm/qna.git","svn_url":"https://github.com/alteregoizm/qna","homepage":null,"size":69,"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":"alteregoizm:master","ref":"master","sha":"d7914afebca68e6b8a11b9b623c803723c235ec1","user":{"login":"alteregoizm","id":11354098,"avatar_url":"https://avatars.githubusercontent.com/u/11354098?v=3","gravatar_id":"","url":"https://api.github.com/users/alteregoizm","html_url":"https://github.com/alteregoizm","followers_url":"https://api.github.com/users/alteregoizm/followers","following_url":"https://api.github.com/users/alteregoizm/following{/other_user}","gists_url":"https://api.github.com/users/alteregoizm/gists{/gist_id}","starred_url":"https://api.github.com/users/alteregoizm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteregoizm/subscriptions","organizations_url":"https://api.github.com/users/alteregoizm/orgs","repos_url":"https://api.github.com/users/alteregoizm/repos","events_url":"https://api.github.com/users/alteregoizm/events{/privacy}","received_events_url":"https://api.github.com/users/alteregoizm/received_events","type":"User","site_admin":false},"repo":{"id":54586382,"name":"qna","full_name":"alteregoizm/qna","owner":{"login":"alteregoizm","id":11354098,"avatar_url":"https://avatars.githubusercontent.com/u/11354098?v=3","gravatar_id":"","url":"https://api.github.com/users/alteregoizm","html_url":"https://github.com/alteregoizm","followers_url":"https://api.github.com/users/alteregoizm/followers","following_url":"https://api.github.com/users/alteregoizm/following{/other_user}","gists_url":"https://api.github.com/users/alteregoizm/gists{/gist_id}","starred_url":"https://api.github.com/users/alteregoizm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteregoizm/subscriptions","organizations_url":"https://api.github.com/users/alteregoizm/orgs","repos_url":"https://api.github.com/users/alteregoizm/repos","events_url":"https://api.github.com/users/alteregoizm/events{/privacy}","received_events_url":"https://api.github.com/users/alteregoizm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alteregoizm/qna","description":"","fork":false,"url":"https://api.github.com/repos/alteregoizm/qna","forks_url":"https://api.github.com/repos/alteregoizm/qna/forks","keys_url":"https://api.github.com/repos/alteregoizm/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alteregoizm/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alteregoizm/qna/teams","hooks_url":"https://api.github.com/repos/alteregoizm/qna/hooks","issue_events_url":"https://api.github.com/repos/alteregoizm/qna/issues/events{/number}","events_url":"https://api.github.com/repos/alteregoizm/qna/events","assignees_url":"https://api.github.com/repos/alteregoizm/qna/assignees{/user}","branches_url":"https://api.github.com/repos/alteregoizm/qna/branches{/branch}","tags_url":"https://api.github.com/repos/alteregoizm/qna/tags","blobs_url":"https://api.github.com/repos/alteregoizm/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alteregoizm/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alteregoizm/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/alteregoizm/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alteregoizm/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/alteregoizm/qna/languages","stargazers_url":"https://api.github.com/repos/alteregoizm/qna/stargazers","contributors_url":"https://api.github.com/repos/alteregoizm/qna/contributors","subscribers_url":"https://api.github.com/repos/alteregoizm/qna/subscribers","subscription_url":"https://api.github.com/repos/alteregoizm/qna/subscription","commits_url":"https://api.github.com/repos/alteregoizm/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/alteregoizm/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/alteregoizm/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/alteregoizm/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/alteregoizm/qna/contents/{+path}","compare_url":"https://api.github.com/repos/alteregoizm/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alteregoizm/qna/merges","archive_url":"https://api.github.com/repos/alteregoizm/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alteregoizm/qna/downloads","issues_url":"https://api.github.com/repos/alteregoizm/qna/issues{/number}","pulls_url":"https://api.github.com/repos/alteregoizm/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/alteregoizm/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/alteregoizm/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alteregoizm/qna/labels{/name}","releases_url":"https://api.github.com/repos/alteregoizm/qna/releases{/id}","deployments_url":"https://api.github.com/repos/alteregoizm/qna/deployments","created_at":"2016-03-23T19:11:48Z","updated_at":"2016-03-23T19:11:53Z","pushed_at":"2016-04-15T14:00:48Z","git_url":"git://github.com/alteregoizm/qna.git","ssh_url":"git@github.com:alteregoizm/qna.git","clone_url":"https://github.com/alteregoizm/qna.git","svn_url":"https://github.com/alteregoizm/qna","homepage":null,"size":69,"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/alteregoizm/qna/pulls/3"},"html":{"href":"https://github.com/alteregoizm/qna/pull/3"},"issue":{"href":"https://api.github.com/repos/alteregoizm/qna/issues/3"},"comments":{"href":"https://api.github.com/repos/alteregoizm/qna/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/alteregoizm/qna/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/alteregoizm/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alteregoizm/qna/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/alteregoizm/qna/statuses/d55d027595bffba88da5f192c1e011c72f27666f"}}}}