Skip to content

Instantly share code, notes, and snippets.

@juggy
Created June 8, 2015 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juggy/5abec1b9d110ff88b823 to your computer and use it in GitHub Desktop.
Save juggy/5abec1b9d110ff88b823 to your computer and use it in GitHub Desktop.
class Core::PaginationSerializer < ActiveModel::ArraySerializer
def initialize(object, options={})
meta_key = options[:meta_key] || :meta
options[meta_key] ||= {}
pobject = options[:pagination_object] || object
options[meta_key][:pagination] = {
current_page: pobject.current_page,
next_page: pobject.next_page,
prev_page: pobject.prev_page,
total_pages: pobject.total_pages,
total_count: pobject.total_count
}
super(object, options)
end
end
@juggy
Copy link
Author

juggy commented Jun 8, 2015

This is for Kaminari (pagination gem) and AMS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment