Class: Naf::HistoricalJobAffinityTabsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/naf/historical_job_affinity_tabs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/naf/historical_job_affinity_tabs_controller.rb', line 30

def create
  @job = Naf::HistoricalJob.find(params[:historical_job_id])
  @tab = Naf::HistoricalJobAffinityTab.new(params[:historical_job_affinity_tab])
  if @tab.save
    redirect_to(naf.historical_job_historical_job_affinity_tab_path(@job, @tab),
                notice: "Historical Job Affinity Tab '#{@tab.affinity_name}' was successfully created.")
  else
    render action: "new", historical_job_id: @job.id
  end
end

#editObject



41
42
43
44
# File 'app/controllers/naf/historical_job_affinity_tabs_controller.rb', line 41

def edit
  @job = Naf::HistoricalJob.find(params[:historical_job_id])
  @tab = Naf::HistoricalJobAffinityTab.find(params[:id])
end

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/naf/historical_job_affinity_tabs_controller.rb', line 6

def index
  @rows = []
  if params[:historical_job_id]
    @rows = Naf::HistoricalJobAffinityTab.where(historical_job_id: params[:historical_job_id])
  end
  render template: 'naf/datatable'
end

#newObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/naf/historical_job_affinity_tabs_controller.rb', line 20

def new
  @job = Naf::HistoricalJob.find(params[:historical_job_id])
  @tab = Naf::HistoricalJobAffinityTab.new

  if @job.present? && @job.finished_at.present?
    flash[:error] = "Can't add an affinity tab to a finished job!"
    redirect_to :back
  end
end

#showObject



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

def show
  @record = Naf::HistoricalJobAffinityTab.find(params[:id])
  @job =    Naf::HistoricalJob.find(params[:historical_job_id])
  render template: 'naf/record'
end

#updateObject



46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/naf/historical_job_affinity_tabs_controller.rb', line 46

def update
  @job = Naf::HistoricalJob.find(params[:historical_job_id])
  @tab = Naf::HistoricalJobAffinityTab.find(params[:id])
  if @tab.update_attributes(params[:historical_job_affinity_tab])
    redirect_to(naf.historical_job_historical_job_affinity_tab_path(@job, @tab),
                notice: "Historical Job Affinity Tab '#{@tab.affinity_name}' was successfully updated.")
  else
    render action: "edit", historical_job_id: @job.id
  end
end