Files
joanna-website/app/controllers/dashboard_controller.rb
T
2026-07-28 11:34:00 -06:00

26 lines
621 B
Ruby

class DashboardController < ApplicationController
def index
joint_column = 'joint'
@available_joints = Joint.distinct.pluck(joint_column)
@available_data
@records = filter_records
respond_to do |format|
format.html
format.json { render json: @records }
end
end
private
def filter_records
# Using .where(joint: params[:joint]) handles both present and nil values gracefully
if params[:joint].present?
Joint.where(joint: params[:joint])
else
# Return empty array if no joint selected to avoid loading thousands of records
[]
end
end
end