Sha256: e6b74faa48820b3bf6b0234b049b822e71ab13591cd40b7d2827900925545aa0
Contents?: true
Size: 983 Bytes
Versions: 1
Compression:
Stored size: 983 Bytes
Contents
# encoding: utf-8 module PagesCore module SearchPagesController extend ActiveSupport::Concern def search @search_query = params[:q] || params[:query] || "" @search_category_id = params[:category_id] @pages = Page.search( normalize_search_query(@search_query), search_options(category_id: @search_category_id) ) @pages.each { |p| p.localize!(locale) } @pages end private def normalize_search_query(str) str.split(/\s+/) .map { |p| "#{p}*" } .join(" ") end def search_options(category_id: nil) options = { page: (params[:page] || 1).to_i, per_page: 20, include: [:localizations, :categories, :image, :author], order: :published_at, sort_mode: :desc, with: { status: 2, autopublish: 0 } } options[:with][:category_ids] = category_id unless category_id.blank? options end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.5.1 | app/controllers/concerns/pages_core/search_pages_controller.rb |