Files
joanna-website/app/controllers/dashboard_controller.rb
T
2026-07-27 20:06:15 -06:00

32 lines
870 B
Ruby

class DashboardController < ApplicationController
def index
joint_column = 'joint'
# Grab distinct values for dropdown filters
@available_joints = Joint.distinct.pluck(joint_column)
# Fetch initial records
@records = filter_records
respond_to do |format|
format.html # Renders app/views/dashboards/index.html.erb
format.json { render json: @records } # Returns filtered data as JSON for JS
end
end
private
def filter_records
records = Joint.all
records = records.where(joint: params[:joint]) if params[:joint].present?
records
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