From e1daade54f15091b0ca4ba06926d33e105a8ecf3 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Tue, 3 Dec 2019 00:47:37 +0100 Subject: [PATCH] Added readout count to index --- app/controllers/measurements_controller.rb | 2 +- app/views/measurements/_index.html.erb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/measurements_controller.rb b/app/controllers/measurements_controller.rb index 84453b2..0523f84 100644 --- a/app/controllers/measurements_controller.rb +++ b/app/controllers/measurements_controller.rb @@ -77,6 +77,6 @@ class MeasurementsController < ApplicationController end def prepare_measurements - @measurements = @project.measurements.includes(:source) + @measurements = @project.measurements.includes(:source, :readouts) end end diff --git a/app/views/measurements/_index.html.erb b/app/views/measurements/_index.html.erb index 5d41ef6..dbef6f0 100644 --- a/app/views/measurements/_index.html.erb +++ b/app/views/measurements/_index.html.erb @@ -13,7 +13,10 @@ <% next if m.new_record? %> <%= m.taken_at.strftime("%F %R") %> - <%= m.name %> + + <%= m.name %> + <%= " (#{m.readouts.size} readouts)" %> + <%= m.source.name if m.source.present? %> <%= link_to l(:button_retake), retake_measurement_path(m), { @@ -31,7 +34,7 @@ ((action_name == "edit") || (action_name == "update" && @measurement.errors.present?)) %> - +
<%= labelled_form_for @measurement, url: measurement_path(@measurement),