Module: Maquina::Index

Extended by:
ActiveSupport::Concern
Includes:
Pagy::Backend
Defined in:
app/controllers/concerns/maquina/index.rb

Overview

The Index concern provides standardized index action functionality for Rails controllers. It includes pagination, authorization, searching, and sorting capabilities.

Features

  • Automatic pagination using Pagy

  • Policy-based authorization support

  • Full-text search integration (when model supports it)

  • Default sorting by updated_at

  • HTML and JSON response formats

  • Customizable scope through block parameter

Dependencies

  • Pagy::Backend

  • Policy class (optional)

  • Model must respond to full_search if searching is used

Usage

class UsersController < ApplicationController
  include Maquina::Index

  def index
    index! do |scope|
      scope.includes(:organization)
    end
  end
end