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

@@ -164,7 +164,7 @@ module ActiveModel
def add_links(options)
links = @hash.fetch(:links) { {} }
resources = serializer.instance_variable_get(:@resource)
@hash[:links] = add_pagination_links(links, resources, options) if @options[:pagination]
@hash[:links] = add_pagination_links(links, resources, options) if options[:pagination]
end
def add_pagination_links(links, resources, options)