mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user