Class: Virgo::SearchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/virgo/search_controller.rb

Instance Method Summary collapse

Methods included from RenderHelper

#render_content, #with_format

Methods included from ApplicationHelper

#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tabbed_param, #word_count

Instance Method Details

#createObject


9
10
11
12
13
14
15
16
17
# File 'app/controllers/virgo/search_controller.rb', line 9

def create
  @search = PostSearch.new(post_search_params)

  if @search.valid?
    redirect_to search_index_path(post_search: post_search_params)
  else
    render :new
  end
end

#indexObject


19
20
21
22
23
24
25
26
27
# File 'app/controllers/virgo/search_controller.rb', line 19

def index
  if post_search_params.nil?
    redirect_to new_search_path and return
  end

  @search = PostSearch.new(post_search_params)

  @posts = Post.search_by_similarity(@search.term).page(params[:page])
end

#newObject


5
6
7
# File 'app/controllers/virgo/search_controller.rb', line 5

def new
  @search = PostSearch.new
end