Class: DomainsController

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


27
28
29
30
31
32
33
34
# File 'app/controllers/domains_controller.rb', line 27

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

#destroyObject


47
48
49
50
51
52
53
# File 'app/controllers/domains_controller.rb', line 47

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

#editObject


36
37
# File 'app/controllers/domains_controller.rb', line 36

def edit
end

#indexObject


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

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

#newObject


16
17
18
19
# File 'app/controllers/domains_controller.rb', line 16

def new
  @domain = Domain.new
  @domain.domain_parameters.build
end

#showObject


21
22
23
24
25
# File 'app/controllers/domains_controller.rb', line 21

def show
  respond_to do |format|
    format.json { render :json => @domain }
  end
end

#updateObject


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

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