Allow searching in logs view

This commit is contained in:
Christoph Haas 2016-08-24 22:41:31 +02:00
parent c467e0ef23
commit 10d5bab37c
2 changed files with 12 additions and 4 deletions

View file

@ -2,6 +2,13 @@ class LogsController < ApplicationController
before_action :authenticate_user!
def index
@logs = Log.paginate(page: params[:page], per_page: 20)
logs = Log
if params[:search].present?
logger.debug "Searching for #{params[:search]}"
logs = logs.where("message ilike ?", "%#{params[:search]}%")
end
@logs = logs.paginate(page: params[:page], per_page: 20)
end
end

View file

@ -6,7 +6,8 @@
.small-6.medium-4.large-3.columns
// Search form
= render 'packages/searchfield'
= form_tag url_for, :method=>'GET'
= text_field_tag(:search, params[:search], placeholder: "Search...", maxlength: 50, size: 20, autofocus: true)
// List of log messages
.row
@ -20,7 +21,7 @@
th =log.created_at
th =log.message
- else
p No logs. Crazy.
p No logs found. Crazy.
// Second paginator at the bottom so the user does not have to scroll up again
// Second paginator at the bottom so the user does not have to scroll up again
= render 'logs/paginator'