{"action":"created","comment":{"url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/comments/89928714","pull_request_review_id":10456911,"id":89928714,"diff_hunk":"@@ -9,39 +77,19 @@ $(function() {\n       dataType:'json',\n       processData: false,\n       contentType: false,\n+      cache: false,\n       data: formData,\n     })\n       .done(function(data) {\n-        // 通信に成功した時の処理\n-        var imageUrl = data.image.image.url\n-        function addImage(image, url){\n-          if (data.image != undefined) {\n-            return '<br /><img src=\"' + url + '\">';\n-          }\n-        }\n-        var message =\n-          '<li class=\"chat__main__body__messages__message\">'                  +\n-          '<div class=\"chat__main__body__messages__message__header\">'         +\n-          '<p class=\"chat__main__body__messages__message__header__name\">'     +\n-          data.name                                                           +\n-          '</p>'                                                              +\n-          '<p class=\"chat__main__body__messages__message__header__date\">'     +\n-          data.created_at                                                     +\n-          '</p>'                                                              +\n-          '</div>'                                                            +\n-          data.body                                                           +\n-          addImage(data.image,imageUrl)                                       +\n-          '</li>';\n-\n-        // 新しいメッセージを追加\n-        $(\"#new-messages\").append(message);\n-        // スクロール\n-        $(\".chat__main__body\").scrollTop( $(\".chat__main__body\")[0].scrollHeight );\n+        // メッセージ追加\n+        addMessage(data);\n+        // 追加後にスクロールする\n+        scroll();\n       })\n       .fail(function(data) {\n-        // 通信に失敗した時の処理","path":"app/assets/javascripts/messages.js","position":112,"original_position":112,"commit_id":"63f9cf5f62a090c9abdadb4fb9e0ae282b9f5414","original_commit_id":"63f9cf5f62a090c9abdadb4fb9e0ae282b9f5414","user":{"login":"mizuki-h","id":18672977,"avatar_url":"https://avatars.githubusercontent.com/u/18672977?v=3","gravatar_id":"","url":"https://api.github.com/users/mizuki-h","html_url":"https://github.com/mizuki-h","followers_url":"https://api.github.com/users/mizuki-h/followers","following_url":"https://api.github.com/users/mizuki-h/following{/other_user}","gists_url":"https://api.github.com/users/mizuki-h/gists{/gist_id}","starred_url":"https://api.github.com/users/mizuki-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mizuki-h/subscriptions","organizations_url":"https://api.github.com/users/mizuki-h/orgs","repos_url":"https://api.github.com/users/mizuki-h/repos","events_url":"https://api.github.com/users/mizuki-h/events{/privacy}","received_events_url":"https://api.github.com/users/mizuki-h/received_events","type":"User","site_admin":false},"body":"コメントアウトで何を実装しているのかがわかりやすく書いてあっていいですね！","created_at":"2016-11-29T02:16:00Z","updated_at":"2016-11-29T02:23:12Z","html_url":"https://github.com/naoki2bota/chat-space/pull/26#discussion_r89928714","pull_request_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/naoki2bota/chat-space/pulls/comments/89928714"},"html":{"href":"https://github.com/naoki2bota/chat-space/pull/26#discussion_r89928714"},"pull_request":{"href":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26","id":95360435,"html_url":"https://github.com/naoki2bota/chat-space/pull/26","diff_url":"https://github.com/naoki2bota/chat-space/pull/26.diff","patch_url":"https://github.com/naoki2bota/chat-space/pull/26.patch","issue_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/26","number":26,"state":"open","locked":false,"title":"自動更新機能の実装","user":{"login":"naoki2bota","id":23024888,"avatar_url":"https://avatars.githubusercontent.com/u/23024888?v=3","gravatar_id":"","url":"https://api.github.com/users/naoki2bota","html_url":"https://github.com/naoki2bota","followers_url":"https://api.github.com/users/naoki2bota/followers","following_url":"https://api.github.com/users/naoki2bota/following{/other_user}","gists_url":"https://api.github.com/users/naoki2bota/gists{/gist_id}","starred_url":"https://api.github.com/users/naoki2bota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoki2bota/subscriptions","organizations_url":"https://api.github.com/users/naoki2bota/orgs","repos_url":"https://api.github.com/users/naoki2bota/repos","events_url":"https://api.github.com/users/naoki2bota/events{/privacy}","received_events_url":"https://api.github.com/users/naoki2bota/received_events","type":"User","site_admin":false},"body":"## WHAT\r\n自動更新機能の実装\r\n-------------Railsの処理---------------------\r\n①A)全レコード(@messages)、送ったidの値を基準にして、B)現在画面に描画済みのレコード(@nowmessages)とC)、増えた差分レコード(@addmessages)を定義。\r\n②A)とB)を比較してA)が多い場合はC)を返す\r\n③返す前に配列をカスタマイズして新しく用意した配列(@appendmessages)に再代入。アソシーエーションでuserモデルのnameを取得する。\r\n④@appendmessagesをjsonで返す。\r\n-----------messages.jsの処理---------------------------\r\n #①ajaxでmessages_controllerのindexアクションにリクエストを送る。（画面に表示されているレコード=`<li></li>`の数をidパラメとして送る）\r\n②返ってきたメッセージをdone()の中で追加描画(addMessage();)\r\n③スクロール(scroll();)\r\n\r\n## WHY\r\n別のユーザーが投稿したらそのメッセージを更新表示するため","created_at":"2016-11-26T04:11:44Z","updated_at":"2016-11-29T02:23:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3e3e5a5741cda334a6b81f2bb0c5c1c2e6efd8c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26/commits","review_comments_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26/comments","review_comment_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls/comments{/number}","comments_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/26/comments","statuses_url":"https://api.github.com/repos/naoki2bota/chat-space/statuses/63f9cf5f62a090c9abdadb4fb9e0ae282b9f5414","head":{"label":"naoki2bota:set_interval_on_message","ref":"set_interval_on_message","sha":"63f9cf5f62a090c9abdadb4fb9e0ae282b9f5414","user":{"login":"naoki2bota","id":23024888,"avatar_url":"https://avatars.githubusercontent.com/u/23024888?v=3","gravatar_id":"","url":"https://api.github.com/users/naoki2bota","html_url":"https://github.com/naoki2bota","followers_url":"https://api.github.com/users/naoki2bota/followers","following_url":"https://api.github.com/users/naoki2bota/following{/other_user}","gists_url":"https://api.github.com/users/naoki2bota/gists{/gist_id}","starred_url":"https://api.github.com/users/naoki2bota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoki2bota/subscriptions","organizations_url":"https://api.github.com/users/naoki2bota/orgs","repos_url":"https://api.github.com/users/naoki2bota/repos","events_url":"https://api.github.com/users/naoki2bota/events{/privacy}","received_events_url":"https://api.github.com/users/naoki2bota/received_events","type":"User","site_admin":false},"repo":{"id":73360084,"name":"chat-space","full_name":"naoki2bota/chat-space","owner":{"login":"naoki2bota","id":23024888,"avatar_url":"https://avatars.githubusercontent.com/u/23024888?v=3","gravatar_id":"","url":"https://api.github.com/users/naoki2bota","html_url":"https://github.com/naoki2bota","followers_url":"https://api.github.com/users/naoki2bota/followers","following_url":"https://api.github.com/users/naoki2bota/following{/other_user}","gists_url":"https://api.github.com/users/naoki2bota/gists{/gist_id}","starred_url":"https://api.github.com/users/naoki2bota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoki2bota/subscriptions","organizations_url":"https://api.github.com/users/naoki2bota/orgs","repos_url":"https://api.github.com/users/naoki2bota/repos","events_url":"https://api.github.com/users/naoki2bota/events{/privacy}","received_events_url":"https://api.github.com/users/naoki2bota/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/naoki2bota/chat-space","description":null,"fork":false,"url":"https://api.github.com/repos/naoki2bota/chat-space","forks_url":"https://api.github.com/repos/naoki2bota/chat-space/forks","keys_url":"https://api.github.com/repos/naoki2bota/chat-space/keys{/key_id}","collaborators_url":"https://api.github.com/repos/naoki2bota/chat-space/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/naoki2bota/chat-space/teams","hooks_url":"https://api.github.com/repos/naoki2bota/chat-space/hooks","issue_events_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/events{/number}","events_url":"https://api.github.com/repos/naoki2bota/chat-space/events","assignees_url":"https://api.github.com/repos/naoki2bota/chat-space/assignees{/user}","branches_url":"https://api.github.com/repos/naoki2bota/chat-space/branches{/branch}","tags_url":"https://api.github.com/repos/naoki2bota/chat-space/tags","blobs_url":"https://api.github.com/repos/naoki2bota/chat-space/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/naoki2bota/chat-space/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/naoki2bota/chat-space/git/refs{/sha}","trees_url":"https://api.github.com/repos/naoki2bota/chat-space/git/trees{/sha}","statuses_url":"https://api.github.com/repos/naoki2bota/chat-space/statuses/{sha}","languages_url":"https://api.github.com/repos/naoki2bota/chat-space/languages","stargazers_url":"https://api.github.com/repos/naoki2bota/chat-space/stargazers","contributors_url":"https://api.github.com/repos/naoki2bota/chat-space/contributors","subscribers_url":"https://api.github.com/repos/naoki2bota/chat-space/subscribers","subscription_url":"https://api.github.com/repos/naoki2bota/chat-space/subscription","commits_url":"https://api.github.com/repos/naoki2bota/chat-space/commits{/sha}","git_commits_url":"https://api.github.com/repos/naoki2bota/chat-space/git/commits{/sha}","comments_url":"https://api.github.com/repos/naoki2bota/chat-space/comments{/number}","issue_comment_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/comments{/number}","contents_url":"https://api.github.com/repos/naoki2bota/chat-space/contents/{+path}","compare_url":"https://api.github.com/repos/naoki2bota/chat-space/compare/{base}...{head}","merges_url":"https://api.github.com/repos/naoki2bota/chat-space/merges","archive_url":"https://api.github.com/repos/naoki2bota/chat-space/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/naoki2bota/chat-space/downloads","issues_url":"https://api.github.com/repos/naoki2bota/chat-space/issues{/number}","pulls_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls{/number}","milestones_url":"https://api.github.com/repos/naoki2bota/chat-space/milestones{/number}","notifications_url":"https://api.github.com/repos/naoki2bota/chat-space/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/naoki2bota/chat-space/labels{/name}","releases_url":"https://api.github.com/repos/naoki2bota/chat-space/releases{/id}","deployments_url":"https://api.github.com/repos/naoki2bota/chat-space/deployments","created_at":"2016-11-10T08:07:22Z","updated_at":"2016-11-10T08:08:51Z","pushed_at":"2016-11-28T16:42:42Z","git_url":"git://github.com/naoki2bota/chat-space.git","ssh_url":"git@github.com:naoki2bota/chat-space.git","clone_url":"https://github.com/naoki2bota/chat-space.git","svn_url":"https://github.com/naoki2bota/chat-space","homepage":null,"size":158,"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":"naoki2bota:master","ref":"master","sha":"c44525b789e55d4faaabf2fc19b8333daa041d37","user":{"login":"naoki2bota","id":23024888,"avatar_url":"https://avatars.githubusercontent.com/u/23024888?v=3","gravatar_id":"","url":"https://api.github.com/users/naoki2bota","html_url":"https://github.com/naoki2bota","followers_url":"https://api.github.com/users/naoki2bota/followers","following_url":"https://api.github.com/users/naoki2bota/following{/other_user}","gists_url":"https://api.github.com/users/naoki2bota/gists{/gist_id}","starred_url":"https://api.github.com/users/naoki2bota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoki2bota/subscriptions","organizations_url":"https://api.github.com/users/naoki2bota/orgs","repos_url":"https://api.github.com/users/naoki2bota/repos","events_url":"https://api.github.com/users/naoki2bota/events{/privacy}","received_events_url":"https://api.github.com/users/naoki2bota/received_events","type":"User","site_admin":false},"repo":{"id":73360084,"name":"chat-space","full_name":"naoki2bota/chat-space","owner":{"login":"naoki2bota","id":23024888,"avatar_url":"https://avatars.githubusercontent.com/u/23024888?v=3","gravatar_id":"","url":"https://api.github.com/users/naoki2bota","html_url":"https://github.com/naoki2bota","followers_url":"https://api.github.com/users/naoki2bota/followers","following_url":"https://api.github.com/users/naoki2bota/following{/other_user}","gists_url":"https://api.github.com/users/naoki2bota/gists{/gist_id}","starred_url":"https://api.github.com/users/naoki2bota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naoki2bota/subscriptions","organizations_url":"https://api.github.com/users/naoki2bota/orgs","repos_url":"https://api.github.com/users/naoki2bota/repos","events_url":"https://api.github.com/users/naoki2bota/events{/privacy}","received_events_url":"https://api.github.com/users/naoki2bota/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/naoki2bota/chat-space","description":null,"fork":false,"url":"https://api.github.com/repos/naoki2bota/chat-space","forks_url":"https://api.github.com/repos/naoki2bota/chat-space/forks","keys_url":"https://api.github.com/repos/naoki2bota/chat-space/keys{/key_id}","collaborators_url":"https://api.github.com/repos/naoki2bota/chat-space/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/naoki2bota/chat-space/teams","hooks_url":"https://api.github.com/repos/naoki2bota/chat-space/hooks","issue_events_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/events{/number}","events_url":"https://api.github.com/repos/naoki2bota/chat-space/events","assignees_url":"https://api.github.com/repos/naoki2bota/chat-space/assignees{/user}","branches_url":"https://api.github.com/repos/naoki2bota/chat-space/branches{/branch}","tags_url":"https://api.github.com/repos/naoki2bota/chat-space/tags","blobs_url":"https://api.github.com/repos/naoki2bota/chat-space/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/naoki2bota/chat-space/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/naoki2bota/chat-space/git/refs{/sha}","trees_url":"https://api.github.com/repos/naoki2bota/chat-space/git/trees{/sha}","statuses_url":"https://api.github.com/repos/naoki2bota/chat-space/statuses/{sha}","languages_url":"https://api.github.com/repos/naoki2bota/chat-space/languages","stargazers_url":"https://api.github.com/repos/naoki2bota/chat-space/stargazers","contributors_url":"https://api.github.com/repos/naoki2bota/chat-space/contributors","subscribers_url":"https://api.github.com/repos/naoki2bota/chat-space/subscribers","subscription_url":"https://api.github.com/repos/naoki2bota/chat-space/subscription","commits_url":"https://api.github.com/repos/naoki2bota/chat-space/commits{/sha}","git_commits_url":"https://api.github.com/repos/naoki2bota/chat-space/git/commits{/sha}","comments_url":"https://api.github.com/repos/naoki2bota/chat-space/comments{/number}","issue_comment_url":"https://api.github.com/repos/naoki2bota/chat-space/issues/comments{/number}","contents_url":"https://api.github.com/repos/naoki2bota/chat-space/contents/{+path}","compare_url":"https://api.github.com/repos/naoki2bota/chat-space/compare/{base}...{head}","merges_url":"https://api.github.com/repos/naoki2bota/chat-space/merges","archive_url":"https://api.github.com/repos/naoki2bota/chat-space/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/naoki2bota/chat-space/downloads","issues_url":"https://api.github.com/repos/naoki2bota/chat-space/issues{/number}","pulls_url":"https://api.github.com/repos/naoki2bota/chat-space/pulls{/number}","milestones_url":"https://api.github.com/repos/naoki2bota/chat-space/milestones{/number}","notifications_url":"https://api.github.com/repos/naoki2bota/chat-space/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/naoki2bota/chat-space/labels{/name}","releases_url":"https://api.github.com/repos/naoki2bota/chat-space/releases{/id}","deployments_url":"https://api.github.com/repos/naoki2bota/chat-space/deployments","created_at":"2016-11-10T08:07:22Z","updated_at":"2016-11-10T08:08:51Z","pushed_at":"2016-11-28T16:42:42Z","git_url":"git://github.com/naoki2bota/chat-space.git","ssh_url":"git@github.com:naoki2bota/chat-space.git","clone_url":"https://github.com/naoki2bota/chat-space.git","svn_url":"https://github.com/naoki2bota/chat-space","homepage":null,"size":158,"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/naoki2bota/chat-space/pulls/26"},"html":{"href":"https://github.com/naoki2bota/chat-space/pull/26"},"issue":{"href":"https://api.github.com/repos/naoki2bota/chat-space/issues/26"},"comments":{"href":"https://api.github.com/repos/naoki2bota/chat-space/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/naoki2bota/chat-space/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/naoki2bota/chat-space/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/naoki2bota/chat-space/statuses/63f9cf5f62a090c9abdadb4fb9e0ae282b9f5414"}}}}
{"actor":{"display_login":"mizuki-h"}}