2014-11-19 17:07:05 +01:00
|
|
|
class SearchController < ApplicationController
|
|
|
|
def index
|
2015-04-27 22:35:11 +02:00
|
|
|
@show_search_result = params[:q].present?
|
2015-04-27 23:25:14 +02:00
|
|
|
papers_found = if @show_search_result
|
2015-05-17 19:18:23 +02:00
|
|
|
Paper.search(params[:q]).records
|
2015-04-27 22:35:11 +02:00
|
|
|
else
|
2015-05-17 19:18:23 +02:00
|
|
|
Paper
|
2014-11-19 21:54:36 +01:00
|
|
|
end
|
2015-04-27 23:25:14 +02:00
|
|
|
@papers_count = @show_search_result ? papers_found.results.total : papers_found.count
|
2015-05-17 19:18:23 +02:00
|
|
|
@papers = papers_found.order(published_at: :desc).page(params[:page])
|
2014-11-19 17:07:05 +01:00
|
|
|
end
|
|
|
|
end
|