0.0
Repository is archived
No release in over a year
Code commun des API de Captive
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.5.0
>= 7.0.0
 Project Readme

Captive::Api

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 will_paginate

The pagination method return an hash like this :

{ page: 1, per_page: 20 }

⚠️ The first page is 1 and not 0 !

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.