Class: DailyReportsController

Inherits:
InheritedResources::Base
  • Object
show all
Defined in:
app/controllers/daily_reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#archiveitObject



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

def archiveit
  if @daily_report.archive
    flash[:notice] = "Report has been archived."
  else
    flash[:alert] = "Report has not been archived."
  end
  redirect_to daily_table_daily_report_path(@daily_report.table, @daily_report)
end

#createObject



5
6
7
8
9
10
11
# File 'app/controllers/daily_reports_controller.rb', line 5

def create
  build_resource.user = current_user
  create! do |success, failure|
    success.all { redirect_to daily_table_daily_report_path(@daily_report.table, @daily_report)}
    failure.all { render :new }
  end
end

#destroyObject



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

def destroy
  destroy! { daily_table_path(@daily_report.table) }
end

#generateObject



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

def generate
  @daily_report.queue_now!
  redirect_to daily_table_daily_report_path(@daily_report.table, @daily_report)
end

#unarchiveitObject



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

def unarchiveit
  if @daily_report.unarchive
    flash[:notice] = "Report has been unarchived."
  else
    flash[:alert] = "Report has not been unarchived."
  end
  redirect_to daily_table_daily_report_path(@daily_report.table, @daily_report)
end

#updateObject



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

def update
  update! do |success, failure|
    success.all { redirect_to daily_table_daily_report_path(@daily_report.table, @daily_report)}
    failure.all { render :edit }
  end
end