Sha256: 702fa26fdceaccd6badb13d4936e11be92fe4a42c29c4e0aa60085924ac6b478
Contents?: true
Size: 851 Bytes
Versions: 7
Compression:
Stored size: 851 Bytes
Contents
# frozen_string_literal: true module Maquina module Index extend ActiveSupport::Concern include Pagy::Backend included do def index(&block) authorize! with: policy_class if policy_class.present? @collection ||= begin scope = resource_class.order(updated_at: :desc) scope = authorized_scope(scope) if policy_class.present? search_value = params[:q]&.strip scope = scope.search_full(search_value) if search_value.present? && resource_class.searchable? scope = yield(scope) if block.present? @pagination, record = pagy(scope) record end respond_to do |format| format.html { render :index } format.json { render json: collection } end end alias_method :index!, :index end end end
Version data entries
7 entries across 7 versions & 1 rubygems