Class: ScaptimonyScapContentsController

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

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



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

def create
  @scaptimony_scap_content = ::Scaptimony::ScapContent.new(params[:scap_content])
  if @scaptimony_scap_content.save
    process_success
  else
    process_error
  end
end

#destroy ⇒ Object



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

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

#index ⇒ Object



10
11
12
# File 'app/controllers/scaptimony_scap_contents_controller.rb', line 10

def index
  @contents = resource_base.search_for(params[:search])
end

#model_of_controller ⇒ Object



6
7
8
# File 'app/controllers/scaptimony_scap_contents_controller.rb', line 6

def model_of_controller
  ::Scaptimony::ScapContent
end

#new ⇒ Object



20
21
22
# File 'app/controllers/scaptimony_scap_contents_controller.rb', line 20

def new
  @scaptimony_scap_content = ::Scaptimony::ScapContent.new
end

#show ⇒ Object



14
15
16
17
18
# File 'app/controllers/scaptimony_scap_contents_controller.rb', line 14

def show
  send_data @scaptimony_scap_content.scap_file,
    :type     => 'application/xml',
    :filename => @scaptimony_scap_content.original_filename
end

#update ⇒ Object



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

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

#welcome ⇒ Object



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

def welcome
  @searchbar = true
  if (model_of_controller.first.nil? rescue false)
    @searchbar = false
    render :welcome rescue nil and return
  end
rescue
  not_found
end