stadtratmonitor/app/controllers/search_controller.rb

13 lines
381 B
Ruby
Raw Normal View History

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