{"action":"created","comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/37531761","id":37531761,"diff_hunk":"@@ -0,0 +1,98 @@\n+# How to add pagination links\n+\n+### JSON-API adapter\n+\n+Pagination links will be included in your response automatically as long as the resource is paginated and if you are using a ```JSON-API``` adapter.\n+\n+If you want pagination links in your response, use [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate).\n+\n+```ruby\n+#kaminari example\n+@posts = Kaminari.paginate_array(Post.all).page(3).per(1)\n+render json: @posts\n+\n+#will_paginate example\n+@posts = Post.all.paginate(page: 3, per_page: 1)\n+render json: @posts\n+```\n+\n+```ruby\n+ActiveModel::Serializer.config.adapter = :json_api\n+```\n+\n+ex:\n+```json\n+{\n+  \"data\": [\n+    {\n+      \"type\": \"articles\",\n+      \"id\": \"3\",\n+      \"attributes\": {\n+        \"title\": \"JSON API paints my bikeshed!\",\n+        \"body\": \"The shortest article. Ever.\",\n+        \"created\": \"2015-05-22T14:56:29.000Z\",\n+        \"updated\": \"2015-05-22T14:56:28.000Z\"\n+      }\n+    }\n+  ],\n+  \"links\": {\n+    \"self\": \"http://example.com/articles?page[number]=3&page[size]=1\",\n+    \"first\": \"http://example.com/articles?page[number]=1&page[size]=1\",\n+    \"prev\": \"http://example.com/articles?page[number]=2&page[size]=1\",\n+    \"next\": \"http://example.com/articles?page[number]=4&page[size]=1\",\n+    \"last\": \"http://example.com/articles?page[number]=13&page[size]=1\"\n+  }\n+}\n+```\n+\n+AMS relies on either [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate). Please install either dependency by adding one of those to your Gemfile.","path":"docs/howto/add_pagination_links.md","position":48,"original_position":48,"commit_id":"3c3578a9b83974c6656867c249d60ec1401df3a6","original_commit_id":"3c3578a9b83974c6656867c249d60ec1401df3a6","user":{"login":"bacarini","id":4749909,"avatar_url":"https://avatars.githubusercontent.com/u/4749909?v=3","gravatar_id":"","url":"https://api.github.com/users/bacarini","html_url":"https://github.com/bacarini","followers_url":"https://api.github.com/users/bacarini/followers","following_url":"https://api.github.com/users/bacarini/following{/other_user}","gists_url":"https://api.github.com/users/bacarini/gists{/gist_id}","starred_url":"https://api.github.com/users/bacarini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bacarini/subscriptions","organizations_url":"https://api.github.com/users/bacarini/orgs","repos_url":"https://api.github.com/users/bacarini/repos","events_url":"https://api.github.com/users/bacarini/events{/privacy}","received_events_url":"https://api.github.com/users/bacarini/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-08-20T13:59:05Z","updated_at":"2015-08-20T13:59:05Z","html_url":"https://github.com/rails-api/active_model_serializers/pull/1041#discussion_r37531761","pull_request_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041","_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/37531761"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1041#discussion_r37531761"},"pull_request":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041"}}},"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041","id":41713396,"html_url":"https://github.com/rails-api/active_model_serializers/pull/1041","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1041.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1041.patch","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1041","number":1041,"state":"open","locked":false,"title":"Pagination Links","user":{"login":"bacarini","id":4749909,"avatar_url":"https://avatars.githubusercontent.com/u/4749909?v=3","gravatar_id":"","url":"https://api.github.com/users/bacarini","html_url":"https://github.com/bacarini","followers_url":"https://api.github.com/users/bacarini/followers","following_url":"https://api.github.com/users/bacarini/following{/other_user}","gists_url":"https://api.github.com/users/bacarini/gists{/gist_id}","starred_url":"https://api.github.com/users/bacarini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bacarini/subscriptions","organizations_url":"https://api.github.com/users/bacarini/orgs","repos_url":"https://api.github.com/users/bacarini/repos","events_url":"https://api.github.com/users/bacarini/events{/privacy}","received_events_url":"https://api.github.com/users/bacarini/received_events","type":"User","site_admin":false},"body":"I would like to discuss on how we should display pagination links on AMS.\r\n\r\nI think you can relie on `kaminari`and `will_paginate`gems to do so. Having said that, I created a class to build links.\r\n\r\n[related issue](https://github.com/rails-api/active_model_serializers/issues/1040)","created_at":"2015-08-05T18:58:34Z","updated_at":"2015-08-20T13:59:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3269c95addd7045343990f1822712725bef9c304","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041/commits","review_comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041/comments","review_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1041/comments","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/3c3578a9b83974c6656867c249d60ec1401df3a6","head":{"label":"bacarini:master","ref":"master","sha":"3c3578a9b83974c6656867c249d60ec1401df3a6","user":{"login":"bacarini","id":4749909,"avatar_url":"https://avatars.githubusercontent.com/u/4749909?v=3","gravatar_id":"","url":"https://api.github.com/users/bacarini","html_url":"https://github.com/bacarini","followers_url":"https://api.github.com/users/bacarini/followers","following_url":"https://api.github.com/users/bacarini/following{/other_user}","gists_url":"https://api.github.com/users/bacarini/gists{/gist_id}","starred_url":"https://api.github.com/users/bacarini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bacarini/subscriptions","organizations_url":"https://api.github.com/users/bacarini/orgs","repos_url":"https://api.github.com/users/bacarini/repos","events_url":"https://api.github.com/users/bacarini/events{/privacy}","received_events_url":"https://api.github.com/users/bacarini/received_events","type":"User","site_admin":false},"repo":{"id":40079775,"name":"active_model_serializers","full_name":"bacarini/active_model_serializers","owner":{"login":"bacarini","id":4749909,"avatar_url":"https://avatars.githubusercontent.com/u/4749909?v=3","gravatar_id":"","url":"https://api.github.com/users/bacarini","html_url":"https://github.com/bacarini","followers_url":"https://api.github.com/users/bacarini/followers","following_url":"https://api.github.com/users/bacarini/following{/other_user}","gists_url":"https://api.github.com/users/bacarini/gists{/gist_id}","starred_url":"https://api.github.com/users/bacarini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bacarini/subscriptions","organizations_url":"https://api.github.com/users/bacarini/orgs","repos_url":"https://api.github.com/users/bacarini/repos","events_url":"https://api.github.com/users/bacarini/events{/privacy}","received_events_url":"https://api.github.com/users/bacarini/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bacarini/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":true,"url":"https://api.github.com/repos/bacarini/active_model_serializers","forks_url":"https://api.github.com/repos/bacarini/active_model_serializers/forks","keys_url":"https://api.github.com/repos/bacarini/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bacarini/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bacarini/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/bacarini/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/bacarini/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/bacarini/active_model_serializers/events","assignees_url":"https://api.github.com/repos/bacarini/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/bacarini/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/bacarini/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/bacarini/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bacarini/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bacarini/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/bacarini/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bacarini/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/bacarini/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/bacarini/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/bacarini/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/bacarini/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/bacarini/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/bacarini/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/bacarini/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/bacarini/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/bacarini/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/bacarini/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/bacarini/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bacarini/active_model_serializers/merges","archive_url":"https://api.github.com/repos/bacarini/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bacarini/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/bacarini/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/bacarini/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/bacarini/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/bacarini/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bacarini/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/bacarini/active_model_serializers/releases{/id}","created_at":"2015-08-02T13:13:01Z","updated_at":"2015-08-02T13:13:03Z","pushed_at":"2015-08-19T14:16:58Z","git_url":"git://github.com/bacarini/active_model_serializers.git","ssh_url":"git@github.com:bacarini/active_model_serializers.git","clone_url":"https://github.com/bacarini/active_model_serializers.git","svn_url":"https://github.com/bacarini/active_model_serializers","homepage":"","size":1591,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails-api:master","ref":"master","sha":"e384b65f5d085937eb40ede9c6c65b96a7557e2c","user":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"repo":{"id":2889230,"name":"active_model_serializers","full_name":"rails-api/active_model_serializers","owner":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails-api/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":false,"url":"https://api.github.com/repos/rails-api/active_model_serializers","forks_url":"https://api.github.com/repos/rails-api/active_model_serializers/forks","keys_url":"https://api.github.com/repos/rails-api/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails-api/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails-api/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/rails-api/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/events","assignees_url":"https://api.github.com/repos/rails-api/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/rails-api/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/rails-api/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/rails-api/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/rails-api/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails-api/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/rails-api/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails-api/active_model_serializers/merges","archive_url":"https://api.github.com/repos/rails-api/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails-api/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/rails-api/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/rails-api/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/rails-api/active_model_serializers/releases{/id}","created_at":"2011-12-01T06:39:26Z","updated_at":"2015-08-20T06:40:51Z","pushed_at":"2015-08-20T06:53:13Z","git_url":"git://github.com/rails-api/active_model_serializers.git","ssh_url":"git@github.com:rails-api/active_model_serializers.git","clone_url":"https://github.com/rails-api/active_model_serializers.git","svn_url":"https://github.com/rails-api/active_model_serializers","homepage":"","size":5676,"stargazers_count":2909,"watchers_count":2909,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":664,"mirror_url":null,"open_issues_count":145,"forks":664,"open_issues":145,"watchers":2909,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1041"},"issue":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1041"},"comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1041/comments"},"review_comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041/comments"},"review_comment":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1041/commits"},"statuses":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/3c3578a9b83974c6656867c249d60ec1401df3a6"}}}}