Class: SourceMonitor::ItemsController

Inherits:
ApplicationController show all
Includes:
ActionView::RecordIdentifier, SanitizesSearchParams
Defined in:
app/controllers/source_monitor/items_controller.rb

Constant Summary collapse

PER_PAGE =
25
SEARCH_FIELD =
:title_or_summary_or_url_or_source_name_cont

Instance Method Summary collapse

Instance Method Details

#indexObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/source_monitor/items_controller.rb', line 16

def index
  @search_params = sanitized_search_params
  @q = build_search_query

  scope = @q.result(distinct: true)
  paginator = SourceMonitor::Pagination::Paginator.new(
    scope:,
    page: params[:page],
    per_page: PER_PAGE
  ).paginate

  @paginator = paginator
  @items = paginator.records
  @page = paginator.page
  @has_next_page = paginator.has_next_page
  @has_previous_page = paginator.has_previous_page

  @search_term = @search_params[SEARCH_FIELD.to_s].to_s.strip
  @search_field = SEARCH_FIELD
end

#showObject



37
38
# File 'app/controllers/source_monitor/items_controller.rb', line 37

def show
end