Class: SearchEntries

Inherits:
Application show all
Defined in:
app/controllers/search_entries.rb

Overview

require ‘chef’ / ‘search’ require ‘chef’ / ‘queue’

Instance Method Summary collapse

Methods inherited from Application

#access_denied, #append_tree, #bad_request?, #binary?, #build_tree, #can_edit_admin?, #cleanup_session, #conflict?, #convert_newline_to_br, #determine_name, #forbidden?, #format_exception, #is_admin?, #is_last_admin?, #list_available_recipes_for, #load_cookbook_segment, #load_environments, #load_session_user, #login_required, #logout_and_redirect_to_login, #not_found?, #redirect_back_or_default, #require_admin, #segment_files, #show_plain_file, #store_location, #str_to_bool, #syntax_highlight

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/search_entries.rb', line 40

def create
  @to_index = params
  @to_index.delete(:controller)
  @to_index["index_name"] = params[:search_id]
  @to_index["id"] = "#{params[:search_id]}_#{params[:id]}"
  @to_index.delete(:search_id)
  Chef::Queue.send_msg(:queue, :index, @to_index)
  redirect url(:search)
end

#destroyObject



54
55
56
57
58
59
60
61
62
# File 'app/controllers/search_entries.rb', line 54

def destroy
  @s = Chef::Search.new
  @entries = @s.search(params[:id])
  @entries.each do |entry|
    Chef::Queue.send_msg(:queue, :remove, entry)
  end
  @status = 202
  redirect url(:search)
end

#indexObject



28
29
30
31
32
# File 'app/controllers/search_entries.rb', line 28

def index
  @s = Chef::Search.new
  @entries = @s.search(params[:search_id])
  render
end

#showObject



34
35
36
37
38
# File 'app/controllers/search_entries.rb', line 34

def show
  @s = Chef::Search.new
  @entry = @s.search(params[:search_id], "id:'#{params[:search_id]}_#{params[:id]}'").first
  render
end

#updateObject



50
51
52
# File 'app/controllers/search_entries.rb', line 50

def update
  create
end