From 7ebf6dbf413769b3f6ca10082c7bcd0d76bce883 Mon Sep 17 00:00:00 2001 From: bionickatana Date: Mon, 27 Jul 2026 21:55:41 -0600 Subject: [PATCH] working basic state --- app/controllers/dashboard_controller.rb | 18 +++++++----------- app/views/dashboard/index.html.erb | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index eca156d..c03d033 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -16,16 +16,12 @@ class DashboardController < ApplicationController private def filter_records - records = Joint.all - records = records.where(joint: params[:joint]) if params[:joint].present? - records + if params.include?(:joint) + records = Joint.all + records = records.where(joint: params[:joint]) + records + else + [] + end end - - # old broken: def index - # old broken: @joint = Joint.distinct.pluck(:Joint) - # old broken: - # old broken: @records = Joint.all - # old broken: - # old broken: @records = @records.where(Joint: params[joint]) if params[:joint].present? - # old broken: end end diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 6ef7f0e..b1024df 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -4,7 +4,7 @@ <%= form_with url: dashboard_path, method: :get, id: "filter-form" do |f| %>
<%= f.label :joint, "Select Joint:" %> - <%= f.select :joint, options_for_select(@available_joints, params[:joint]), include_blank: "All joints", id: "joint" %> + <%= f.select :joint, options_for_select(@available_joints, params[:joint]), include_blank: "Select a joint", id: "joint" %>
<% end %>