Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

paginate-responder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paginate-responder

  • 2.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Paginate::Responder

Gem Build Status Code Climate maintainability

A Rails pagination responder with link header support.

Installation

Add this line to your application's Gemfile:

gem 'paginate-responder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paginate-responder

You will also need a pagination gem. PaginateResponder comes with adapters for

It is recommended to use only one pagination gem at once.

Usage

Add Responders::PaginateResponder to your responder chain:

class AppResponder < Responder
  include Responders::PaginateResponder
end

class MyController < ApplicationController
  self.responder = AppResponder
end

Or use it with plataformatec/responders:

class MyController < ApplicationController
  responders Responders::PaginateResponder
end

PaginateResponder will add the following link headers to non HTML responses:

  • first First page's URL.
  • last Last page's URL.
  • next Next page's URL.
  • prev Previous page's URL.

next and prev page links will not be added if current page is first or last page.

Also a X-Total-Pages header will be added with the total number of pages if available and a X-Total-Count header with the total number of items. This allows applications to display a progress bar or similar while fetching pages.

Override page detections and options

You can override the page detection by creating a method page in your controller that returns the page index as a fixnum:

class ApplicationController
  def page
    params[:seite].to_i # seite means page in German
  end
end

Same goes for per_page and max_per_page:

class ApplicationController
  def per_page
    10
  end

  def max_per_page
    25
  end
end

TODOs

  • Documentation ** Controller methods

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add tests for your feature.
  4. Add your feature.
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

License

MIT License

Copyright (c) 2013, Jan Graichen

FAQs

Package last updated on 28 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc