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: 10 }

⚠️ 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.