Skip to content

Latest commit

 

History

History
105 lines (69 loc) · 2.54 KB

README.md

File metadata and controls

105 lines (69 loc) · 2.54 KB

Captive::API

License: MIT Gem Version

Code commun des API de Captive

Usage

How to use my plugin.

Implementation :

module API
  module V1
    class BaseController < Captive::API::ApplicationController
      ...
    end
  end
end

The class Captive::API::ApplicationController includes 2 concerns :

Nom du concern Description
pagination Logique de pagination pour les index
render error Attrape certaines erreurs pour retourner une page d'erreur en json. Permet aussi d'utiliser les méthodes pour rendre des pages d'erreur json manuellement

PaginationConcern

#pagination

You can use the pagination method like this :

@tenues = @tenues.page(pagination[:page])
                 .per(pagination[:per_page])

The method page and per come from kaminari

The pagination method return an hash like this :

{ page: 1, per_page: 20 }

⚠️ The first page is 1 and not 0 !

  • The default number of item per page is 20 You can change with setting this constant into your controller : DEFAULT_NB_ITEMS_PAR_PAGE = 50

  • The default max number of item per page is 100 You can change with setting this constant into your controller : MAX_ITEMS_PAR_PAGE = 200

RenderErrorConcern

TODO

Installation

Add this line to your application's Gemfile:

gem "captive-api"

And then execute:

bundle

Or install it yourself as:

gem install captive-api

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

About Captive

captive

captive-api is maintained and funded by Captive. The names and logos for captive are trademarks of captive-studio.

We love open source software! See our other projects or hire us to design, develop, and grow your product.