Code commun des API de Captive
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 |
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 }
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
TODO
Add this line to your application's Gemfile:
gem "captive-api"
And then execute:
bundle
Or install it yourself as:
gem install captive-api
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.
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.