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| %>