lib/paginate-responder/paginator.rb in paginate-responder-1.4.2 vs lib/paginate-responder/paginator.rb in paginate-responder-1.5.0
- old
+ new
@@ -40,13 +40,16 @@
link! 'next', page + 1 if total_pages && page < total_pages
link! 'last', total_pages if total_pages
response.headers["X-Total-Pages"] = total_pages.to_s if total_pages
response.headers["X-Total-Count"] = total_count.to_s if total_count
+ response.headers["X-Per-Page"] = per_page.to_s
end
def link!(rel, page)
- response.link(controller.url_for(request.params.merge(:page => page)), :rel => rel)
+ pagination_params = { :page => page }
+ pagination_params[:per_page] = per_page if request.params.has_key?(:per_page)
+ response.link(controller.url_for(request.params.merge(pagination_params)), :rel => rel)
end
def resource!
@resource = @adapter.paginate! :page => page, :per_page => per_page
end