{"action":"created","comment":{"url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/comments/38832904","id":38832904,"diff_hunk":"@@ -1,6 +1,9 @@\n class Prototypes::PrototypesController < ApplicationController\n+\n   def index\n-    @prototypes = Prototype.page(params[:page]).includes(:user, :prototype_images, :tags)\n+    popular_ids = Prototype.joins('left join likes on prototypes.id = likes.prototype_id').group('prototypes.id').order('count_prototype_id desc').count('prototype_id').keys\n+    @prototypes = Prototype.where(id: popular_ids).includes(:user, :prototype_images, :tags).page(params[:page]).index_by(&:id).slice(*popular_ids).values\n+    @prototype_pagination = Prototype.where(id: popular_ids).page(params[:page])","path":"app/controllers/prototypes/prototypes_controller.rb","position":null,"original_position":7,"commit_id":"a960feb51745242f01ea6d6c8773d410c919c68f","original_commit_id":"526942a674b9f54296416cac80068433e6752c9d","user":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"body":"このような書き方があるのですね。\r\n知りませんでした。この書き方であれば、prototypeモデルではないのでperを書く必要がありますね。\r\n\r\n```\r\n@prototype_pagination = Kaminari.pagenate_array(@prototypes).page(params[:page]).per(num)\r\n```\r\n","created_at":"2015-09-07T04:26:12Z","updated_at":"2015-09-07T04:26:12Z","html_url":"https://github.com/kuboshizuma/protospace/pull/12#discussion_r38832904","pull_request_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/comments/38832904"},"html":{"href":"https://github.com/kuboshizuma/protospace/pull/12#discussion_r38832904"},"pull_request":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12","id":44282622,"html_url":"https://github.com/kuboshizuma/protospace/pull/12","diff_url":"https://github.com/kuboshizuma/protospace/pull/12.diff","patch_url":"https://github.com/kuboshizuma/protospace/pull/12.patch","issue_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/12","number":12,"state":"open","locked":false,"title":"[update] sort popular proto by the number of likes","user":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"body":"# WHAT\r\nプロトタイプの一覧ページの「popular PROTO」をlike数の順にソートを行った。","created_at":"2015-09-05T13:06:58Z","updated_at":"2015-09-07T04:26:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4083b8454ada81e40b92890d46b688f5ba88b44e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12/commits","review_comments_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12/comments","review_comment_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/12/comments","statuses_url":"https://api.github.com/repos/kuboshizuma/protospace/statuses/a960feb51745242f01ea6d6c8773d410c919c68f","head":{"label":"kuboshizuma:popular","ref":"popular","sha":"a960feb51745242f01ea6d6c8773d410c919c68f","user":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"repo":{"id":40795208,"name":"protospace","full_name":"kuboshizuma/protospace","owner":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kuboshizuma/protospace","description":"作成したプロトタイプを投稿出来るサービス","fork":false,"url":"https://api.github.com/repos/kuboshizuma/protospace","forks_url":"https://api.github.com/repos/kuboshizuma/protospace/forks","keys_url":"https://api.github.com/repos/kuboshizuma/protospace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kuboshizuma/protospace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kuboshizuma/protospace/teams","hooks_url":"https://api.github.com/repos/kuboshizuma/protospace/hooks","issue_events_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/events{/number}","events_url":"https://api.github.com/repos/kuboshizuma/protospace/events","assignees_url":"https://api.github.com/repos/kuboshizuma/protospace/assignees{/user}","branches_url":"https://api.github.com/repos/kuboshizuma/protospace/branches{/branch}","tags_url":"https://api.github.com/repos/kuboshizuma/protospace/tags","blobs_url":"https://api.github.com/repos/kuboshizuma/protospace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kuboshizuma/protospace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kuboshizuma/protospace/git/refs{/sha}","trees_url":"https://api.github.com/repos/kuboshizuma/protospace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kuboshizuma/protospace/statuses/{sha}","languages_url":"https://api.github.com/repos/kuboshizuma/protospace/languages","stargazers_url":"https://api.github.com/repos/kuboshizuma/protospace/stargazers","contributors_url":"https://api.github.com/repos/kuboshizuma/protospace/contributors","subscribers_url":"https://api.github.com/repos/kuboshizuma/protospace/subscribers","subscription_url":"https://api.github.com/repos/kuboshizuma/protospace/subscription","commits_url":"https://api.github.com/repos/kuboshizuma/protospace/commits{/sha}","git_commits_url":"https://api.github.com/repos/kuboshizuma/protospace/git/commits{/sha}","comments_url":"https://api.github.com/repos/kuboshizuma/protospace/comments{/number}","issue_comment_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/comments{/number}","contents_url":"https://api.github.com/repos/kuboshizuma/protospace/contents/{+path}","compare_url":"https://api.github.com/repos/kuboshizuma/protospace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kuboshizuma/protospace/merges","archive_url":"https://api.github.com/repos/kuboshizuma/protospace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kuboshizuma/protospace/downloads","issues_url":"https://api.github.com/repos/kuboshizuma/protospace/issues{/number}","pulls_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls{/number}","milestones_url":"https://api.github.com/repos/kuboshizuma/protospace/milestones{/number}","notifications_url":"https://api.github.com/repos/kuboshizuma/protospace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kuboshizuma/protospace/labels{/name}","releases_url":"https://api.github.com/repos/kuboshizuma/protospace/releases{/id}","created_at":"2015-08-16T01:39:14Z","updated_at":"2015-08-16T01:41:56Z","pushed_at":"2015-09-07T04:16:22Z","git_url":"git://github.com/kuboshizuma/protospace.git","ssh_url":"git@github.com:kuboshizuma/protospace.git","clone_url":"https://github.com/kuboshizuma/protospace.git","svn_url":"https://github.com/kuboshizuma/protospace","homepage":null,"size":1347,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"kuboshizuma:master","ref":"master","sha":"afa049a6db73226468370d88f714f19e61acfc66","user":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"repo":{"id":40795208,"name":"protospace","full_name":"kuboshizuma/protospace","owner":{"login":"kuboshizuma","id":7121842,"avatar_url":"https://avatars.githubusercontent.com/u/7121842?v=3","gravatar_id":"","url":"https://api.github.com/users/kuboshizuma","html_url":"https://github.com/kuboshizuma","followers_url":"https://api.github.com/users/kuboshizuma/followers","following_url":"https://api.github.com/users/kuboshizuma/following{/other_user}","gists_url":"https://api.github.com/users/kuboshizuma/gists{/gist_id}","starred_url":"https://api.github.com/users/kuboshizuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuboshizuma/subscriptions","organizations_url":"https://api.github.com/users/kuboshizuma/orgs","repos_url":"https://api.github.com/users/kuboshizuma/repos","events_url":"https://api.github.com/users/kuboshizuma/events{/privacy}","received_events_url":"https://api.github.com/users/kuboshizuma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kuboshizuma/protospace","description":"作成したプロトタイプを投稿出来るサービス","fork":false,"url":"https://api.github.com/repos/kuboshizuma/protospace","forks_url":"https://api.github.com/repos/kuboshizuma/protospace/forks","keys_url":"https://api.github.com/repos/kuboshizuma/protospace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kuboshizuma/protospace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kuboshizuma/protospace/teams","hooks_url":"https://api.github.com/repos/kuboshizuma/protospace/hooks","issue_events_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/events{/number}","events_url":"https://api.github.com/repos/kuboshizuma/protospace/events","assignees_url":"https://api.github.com/repos/kuboshizuma/protospace/assignees{/user}","branches_url":"https://api.github.com/repos/kuboshizuma/protospace/branches{/branch}","tags_url":"https://api.github.com/repos/kuboshizuma/protospace/tags","blobs_url":"https://api.github.com/repos/kuboshizuma/protospace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kuboshizuma/protospace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kuboshizuma/protospace/git/refs{/sha}","trees_url":"https://api.github.com/repos/kuboshizuma/protospace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kuboshizuma/protospace/statuses/{sha}","languages_url":"https://api.github.com/repos/kuboshizuma/protospace/languages","stargazers_url":"https://api.github.com/repos/kuboshizuma/protospace/stargazers","contributors_url":"https://api.github.com/repos/kuboshizuma/protospace/contributors","subscribers_url":"https://api.github.com/repos/kuboshizuma/protospace/subscribers","subscription_url":"https://api.github.com/repos/kuboshizuma/protospace/subscription","commits_url":"https://api.github.com/repos/kuboshizuma/protospace/commits{/sha}","git_commits_url":"https://api.github.com/repos/kuboshizuma/protospace/git/commits{/sha}","comments_url":"https://api.github.com/repos/kuboshizuma/protospace/comments{/number}","issue_comment_url":"https://api.github.com/repos/kuboshizuma/protospace/issues/comments{/number}","contents_url":"https://api.github.com/repos/kuboshizuma/protospace/contents/{+path}","compare_url":"https://api.github.com/repos/kuboshizuma/protospace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kuboshizuma/protospace/merges","archive_url":"https://api.github.com/repos/kuboshizuma/protospace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kuboshizuma/protospace/downloads","issues_url":"https://api.github.com/repos/kuboshizuma/protospace/issues{/number}","pulls_url":"https://api.github.com/repos/kuboshizuma/protospace/pulls{/number}","milestones_url":"https://api.github.com/repos/kuboshizuma/protospace/milestones{/number}","notifications_url":"https://api.github.com/repos/kuboshizuma/protospace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kuboshizuma/protospace/labels{/name}","releases_url":"https://api.github.com/repos/kuboshizuma/protospace/releases{/id}","created_at":"2015-08-16T01:39:14Z","updated_at":"2015-08-16T01:41:56Z","pushed_at":"2015-09-07T04:16:22Z","git_url":"git://github.com/kuboshizuma/protospace.git","ssh_url":"git@github.com:kuboshizuma/protospace.git","clone_url":"https://github.com/kuboshizuma/protospace.git","svn_url":"https://github.com/kuboshizuma/protospace","homepage":null,"size":1347,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12"},"html":{"href":"https://github.com/kuboshizuma/protospace/pull/12"},"issue":{"href":"https://api.github.com/repos/kuboshizuma/protospace/issues/12"},"comments":{"href":"https://api.github.com/repos/kuboshizuma/protospace/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kuboshizuma/protospace/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/kuboshizuma/protospace/statuses/a960feb51745242f01ea6d6c8773d410c919c68f"}}}}