stadtratmonitor/app/controllers/search_controller.rb
2015-04-27 23:28:35 +02:00

12 lines
381 B
Ruby

class SearchController < ApplicationController
def index
@show_search_result = params[:q].present?
papers_found = if @show_search_result
Paper.search(params[:q])
else
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