Super basic version
This commit is contained in:
@@ -1,2 +1,31 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user