Class: EnvironmentsController

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

Instance Method Summary collapse

Methods included from Foreman::Controller::AutoCompleteSearch

#auto_complete_search, #invalid_search_query

Methods included from Foreman::Controller::Environments

#import_environments, #obsolete_and_new

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#createObject


29
30
31
32
33
34
35
36
# File 'app/controllers/environments_controller.rb', line 29

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

#destroyObject


49
50
51
52
53
54
55
# File 'app/controllers/environments_controller.rb', line 49

def destroy
  if @environment.destroy
    process_success
  else
    process_error
  end
end

#editObject


38
39
# File 'app/controllers/environments_controller.rb', line 38

def edit
end

#indexObject


7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/environments_controller.rb', line 7

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

#newObject


25
26
27
# File 'app/controllers/environments_controller.rb', line 25

def new
  @environment = Environment.new
end

#showObject


18
19
20
21
22
23
# File 'app/controllers/environments_controller.rb', line 18

def show
  respond_to do |format|
    format.html { invalid_request }
    format.json { render :json => @environment.as_json(:include => :hosts)}
  end
end

#updateObject


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

def update
  if @environment.update_attributes(params[:environment])
    process_success
  else
    process_error
  end
end