Silly read only databases...
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
class JointsController < ApplicationController
|
||||
def index
|
||||
# Grab values:
|
||||
@available_categories = JointsDashboard.distinct.pluck(:Joint)
|
||||
|
||||
# Start with base query:
|
||||
@records = JointsDashboard.all
|
||||
|
||||
# Filter data based on dropdown selection params
|
||||
@records = @records.where(Joint: params[:joint]) if params[:joint].present?
|
||||
#@records = @records.where(Joint == params[:joint]) if params[:joint].present?
|
||||
puts @records
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
class JointsDashboard < ApplicationRecord
|
||||
self.table_name = "Joints"
|
||||
|
||||
# Prevent actidental updates from code:
|
||||
def readonly?
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
<h1>Excel Replacement Dashboard</h1>
|
||||
|
||||
<!-- Dropdown Filters Form -->
|
||||
<%= form_with url: dashboard_path, method: :get, local: true do |f| %>
|
||||
<div>
|
||||
<%= f.label :category, "Select Category:" %>
|
||||
<%= f.select :category, options_for_select(@available_categories, params[:category]), include_blank: "All Categories" %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.label :region, "Select Region:" %>
|
||||
<%= f.select :region, options_for_select(@available_regions, params[:region]), include_blank: "All Regions" %>
|
||||
</div>
|
||||
|
||||
<%= f.submit "Filter Data" %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Displaying the Data in Specific Locations / Table -->
|
||||
<h2>Dashboard Results</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Column 1</th>
|
||||
<th>Column 2</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @records.each do |record| %>
|
||||
<tr>
|
||||
<td><%= record.category_column %></td>
|
||||
<td><%= record.region_column %></td>
|
||||
<td><%= record.metric_value_column %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
Reference in New Issue
Block a user