Sort by published_at

This commit is contained in:
Andreas Haller 2015-05-17 19:18:23 +02:00
parent 46de026234
commit b1197df490

View file

@ -2,11 +2,11 @@ class SearchController < ApplicationController
def index def index
@show_search_result = params[:q].present? @show_search_result = params[:q].present?
papers_found = if @show_search_result papers_found = if @show_search_result
Paper.search(params[:q]) Paper.search(params[:q]).records
else else
Paper.order(published_at: :desc) Paper
end end
@papers_count = @show_search_result ? papers_found.results.total : papers_found.count @papers_count = @show_search_result ? papers_found.results.total : papers_found.count
@papers = papers_found.page(params[:page]) @papers = papers_found.order(published_at: :desc).page(params[:page])
end end
end end