Class: CurrentScope::EventsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/current_scope/events_controller.rb

Overview

Read-only view of the append-only audit ledger. Inherits the full-access gate and mutation guard from ApplicationController; there is no write path.

Constant Summary collapse

PER_PAGE =
50

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
10
11
12
# File 'app/controllers/current_scope/events_controller.rb', line 7

def index
  @page = [ params[:page].to_i, 1 ].max
  scope = Event.order(id: :desc)
  @events = scope.limit(PER_PAGE).offset((@page - 1) * PER_PAGE)
  @has_next_page = scope.offset(@page * PER_PAGE).exists?
end