Class: TailoringFilesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch, Foreman::Controller::Parameters::TailoringFile
Defined in:
app/controllers/tailoring_files_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/tailoring_files_controller.rb', line 20

def create
  @tailoring_file = ForemanOpenscap::TailoringFile.new(tailoring_file_params)
  if @tailoring_file.save
    process_success
  else
    process_error
  end
rescue RestClient::Exception => e
  @tailoring_file.errors.add(:scap_file, :invalid, message: e.http_body)
  process_error
end

#destroyObject



43
44
45
46
47
48
49
# File 'app/controllers/tailoring_files_controller.rb', line 43

def destroy
  if @tailoring_file.destroy
    process_success
  else
    process_error :object => @tailoring_file
  end
end

#editObject



32
33
# File 'app/controllers/tailoring_files_controller.rb', line 32

def edit
end

#indexObject



12
13
14
# File 'app/controllers/tailoring_files_controller.rb', line 12

def index
  @tailoring_files = resource_base_search_and_page.search_for(params[:search])
end

#model_of_controllerObject



8
9
10
# File 'app/controllers/tailoring_files_controller.rb', line 8

def model_of_controller
  ::ForemanOpenscap::TailoringFile
end

#newObject



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

def new
  @tailoring_file = ::ForemanOpenscap::TailoringFile.new
end

#updateObject



35
36
37
38
39
40
41
# File 'app/controllers/tailoring_files_controller.rb', line 35

def update
  if @tailoring_file.update(tailoring_file_params)
    process_success
  else
    process_error
  end
end

#xmlObject



51
52
53
54
55
# File 'app/controllers/tailoring_files_controller.rb', line 51

def xml
  send_data @tailoring_file.scap_file,
            :type     => 'application/xml',
            :filename => @tailoring_file.original_filename || "#{@tailoring_file.name}.xml"
end