Class: LookupValuesController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/lookup_values_controller.rb

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


23
24
25
26
27
28
29
30
# File 'app/controllers/lookup_values_controller.rb', line 23

def create
  @lookup_value = LookupValue.new(params[:lookup_value])
  if @lookup_value.save
    process_success({:success_redirect => lookup_key_lookup_values_url(params[:lookup_key_id])})
  else
    process_error
  end
end

#destroyObject


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

def destroy
  if @lookup_value.destroy
    process_success({:success_redirect => lookup_key_lookup_values_url(params[:lookup_key_id])})
  else
    process_error
  end
end

#indexObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/lookup_values_controller.rb', line 7

def index
  begin
    values = LookupValue.search_for(params[:search], :order => params[:order])
  rescue => e
    error e.to_s
    values = LookupValue.search_for ""
  end

  respond_to do |format|
    format.html do
      @lookup_values = values.paginate(:page => params[:page])
    end
    format.json { render :json => values}
  end
end

#updateObject


32
33
34
35
36
37
38
# File 'app/controllers/lookup_values_controller.rb', line 32

def update
  if @lookup_value.update_attributes(params[:lookup_value])
    process_success({:success_redirect => lookup_key_lookup_values_url(params[:lookup_key_id])})
  else
    process_error
  end
end