Add pagination links automatically

Pagination links will be included in your response automatically as long
as the resource is paginated using Kaminari or WillPaginate
and if you are using a JSON-API adapter. The others adapters does not have this feature.
This commit is contained in:
Bruno Bacarini
2015-08-17 14:25:59 -03:00
parent a41d90cce4
commit 2c2f948fa0
8 changed files with 52 additions and 47 deletions

View File

@@ -31,19 +31,16 @@ module ActionController
end
def render_pagination_using_kaminari
render json: using_kaminari, adapter: :json_api, pagination: true
render json: using_kaminari, adapter: :json_api
end
def render_pagination_using_will_paginate
render json: using_will_paginate, adapter: :json_api, pagination: true
render json: using_will_paginate, adapter: :json_api
end
def render_array_without_pagination_links
render json: using_will_paginate, adapter: :json_api, pagination: false
end
def render_array_omitting_pagination_options
render json: using_kaminari, adapter: :json_api
setup
render json: @array, adapter: :json_api
end
end
@@ -104,12 +101,6 @@ module ActionController
response = JSON.parse(@response.body)
refute response.key? 'links'
end
def test_array_omitting_pagination_options
get :render_array_omitting_pagination_options, page: { number: 2, size: 1 }
response = JSON.parse(@response.body)
refute response.key? 'links'
end
end
end
end