Sha256: 738c527ee7bb87ff4b24b3fa2bd1ef229ba84c53c06e34d6a7efb847bbb2fff0

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

ApiPagination.configure do |config|
  # If you have more than one gem included, you can choose a paginator.
  config.paginator = :kaminari

  # By default, this is set to 'Total'
  config.total_header = 'X-Total'

  # By default, this is set to 'Per-Page'
  config.per_page_header = 'X-Per-Page'

  # Optional: set this to add a header with the current page number.
  config.page_header = 'X-Page'

  # Optional: set this to add other response format. Useful with tools that define :jsonapi format
  # config.response_formats = [:json, :xml, :jsonapi]
  config.response_formats = [:jsonapi]

  # Optional: what parameter should be used to set the page option
  config.page_param do |params|
    params[:page][:number] if params[:page].is_a?(ActionController::Parameters)
  end

  # Optional: what parameter should be used to set the per page option
  config.per_page_param do |params|
    params[:page][:size] if params[:page].is_a?(ActionController::Parameters)
  end

  # Optional: Include the total and last_page link header
  # By default, this is set to true
  # Note: When using kaminari, this prevents the count call to the database
  config.include_total = true
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
power_api-2.1.1 spec/dummy/config/initializers/api_pagination.rb
power_api-2.1.0 spec/dummy/config/initializers/api_pagination.rb
power_api-2.0.2 spec/dummy/config/initializers/api_pagination.rb
power_api-2.0.1 spec/dummy/config/initializers/api_pagination.rb
power_api-2.0.0 spec/dummy/config/initializers/api_pagination.rb