From 553c1e653c9cf217e43e152ede852149a2594cad Mon Sep 17 00:00:00 2001 From: Andreas Haller Date: Mon, 27 Apr 2015 23:25:14 +0200 Subject: [PATCH] Show the number of all papers on homepage --- app/controllers/search_controller.rb | 8 +++++--- app/views/search/index.html.slim | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index a15cd75..950d451 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,10 +1,12 @@ class SearchController < ApplicationController def index @show_search_result = params[:q].present? - @papers = if @show_search_result - Paper.search(params[:q]).page(params[:page]).results + papers_found = if @show_search_result + Paper.search(params[:q]) else - Paper.order(published_at: :desc).page(params[:page]) + Paper.order(published_at: :desc) end + @papers_count = @show_search_result ? papers_found.results.total : papers_found.count + @papers = papers_found.page(params[:page]) end end diff --git a/app/views/search/index.html.slim b/app/views/search/index.html.slim index 689649e..20da153 100644 --- a/app/views/search/index.html.slim +++ b/app/views/search/index.html.slim @@ -4,9 +4,11 @@ div .clearfix - if @show_search_result .left - | #{@papers.total} Treffer + | #{@papers_count} Treffer .right button.button. TODO: Suche Abbonieren + - else + | #{@papers_count} Dokumente in der Datenbank div ul.no-bullet - @papers.each do |doc|