Class: BrokenWindow::MetricsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/broken_window/metrics_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/broken_window/metrics_controller.rb', line 20

def create
  @metric = Metric.new(metric_params)
  if @metric.save
    redirect_to @metric
  else
    render action: :new
  end
end

#editObject



29
30
31
# File 'app/controllers/broken_window/metrics_controller.rb', line 29

def edit
  @metric = Metric.find(params[:id])
end

#indexObject



5
6
7
8
9
# File 'app/controllers/broken_window/metrics_controller.rb', line 5

def index
  @metrics = Metric.roots.map {|metric| MeasuredMetric.new(metric)}
  @status = MetricStatus.combine(@metrics.map(&:status))
  @body_class = 'background-metric'
end

#newObject



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

def new
  @metric = Metric.new
end

#showObject



11
12
13
14
# File 'app/controllers/broken_window/metrics_controller.rb', line 11

def show
  @metric = MeasuredMetric.find(params[:id])
  @status = @metric.status
end

#updateObject



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

def update
  @metric = Metric.find(params[:id])
  if @metric.update_attributes(metric_params)
    redirect_to @metric
  else
    render action: :edit
  end
end