Class: BrokenWindow::MetricsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BrokenWindow::MetricsController
- Defined in:
- app/controllers/broken_window/metrics_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/broken_window/metrics_controller.rb', line 29 def edit @metric = Metric.find(params[:id]) end |
#index ⇒ Object
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 |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/broken_window/metrics_controller.rb', line 16 def new @metric = Metric.new end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |