Class: SolidStackWeb::CacheEntriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/solid_stack_web/cache_entries_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::PERIOD_DURATIONS

Instance Method Summary collapse

Instance Method Details

#destroyObject



18
19
20
21
22
# File 'app/controllers/solid_stack_web/cache_entries_controller.rb', line 18

def destroy
  ::SolidCache::Entry.find(params[:id]).destroy
  redirect_to cache_entries_path(q: params[:q], column: params[:column], direction: params[:direction]),
              notice: "Cache entry deleted."
end

#indexObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/solid_stack_web/cache_entries_controller.rb', line 3

def index
  @search = params[:q].presence
  @sort   = resolve_sort

  scope = ::SolidCache::Entry.all
  scope = scope.where("key LIKE ?", "%#{::ActiveRecord::Base.sanitize_sql_like(@search)}%") if @search
  scope = scope.order(@sort["column"] => @sort["direction"])

  @pagy, @entries = pagy(scope)
end

#showObject



14
15
16
# File 'app/controllers/solid_stack_web/cache_entries_controller.rb', line 14

def show
  @entry = ::SolidCache::Entry.find(params[:id])
end