Class: ModelsController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/models_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


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

def create
  @model = Model.new(params[:model])
  if @model.save
    process_success
  else
    process_error
  end
end

#destroyObject


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

def destroy
  @model = Model.find(params[:id])
  if @model.destroy
    process_success
  else
    process_error
  end
end

#editObject


28
29
30
# File 'app/controllers/models_controller.rb', line 28

def edit
  @model = Model.find(params[:id])
end

#indexObject


4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/models_controller.rb', line 4

def index
  values = Model.search_for(params[:search], :order => params[:order])
  respond_to do |format|
    format.html do
      @models  = values.paginate :page => params[:page]
      @counter = Host.count(:group => :model_id, :conditions => {:model_id => @models.all})
    end
    format.json { render :json => values }
  end
end

#newObject


15
16
17
# File 'app/controllers/models_controller.rb', line 15

def new
  @model = Model.new
end

#updateObject


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

def update
  @model = Model.find(params[:id])
  if @model.update_attributes(params[:model])
    process_success
  else
    process_error
  end
end