Compare commits
1 Commits
7532b938ed
...
first_try
| Author | SHA1 | Date | |
|---|---|---|---|
| 0172c86958 |
@@ -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>
|
||||
@@ -23,5 +23,8 @@ module Site
|
||||
#
|
||||
# config.time_zone = "Central Time (US & Canada)"
|
||||
# config.eager_load_paths << Rails.root.join("extras")
|
||||
|
||||
# Disable activerecord performing migrations.
|
||||
config.active_record.migration_error = false
|
||||
end
|
||||
end
|
||||
|
||||
+6
-2
@@ -10,8 +10,12 @@ default: &default
|
||||
timeout: 5000
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: storage/development.sqlite3
|
||||
adapter: sqlite3
|
||||
#database: "file:db/anat_proj.db?mode=ro"
|
||||
database: "db/anat_proj.db"
|
||||
#readonly: true
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
|
||||
@@ -75,4 +75,8 @@ Rails.application.configure do
|
||||
|
||||
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
||||
# config.generators.apply_rubocop_autocorrect_after_generate!
|
||||
|
||||
config.active_record.migration_error = false
|
||||
config.log_level = :debug
|
||||
#config.active_record,verbose_query_logs = true
|
||||
end
|
||||
|
||||
@@ -11,4 +11,5 @@ Rails.application.routes.draw do
|
||||
|
||||
# Defines the root path route ("/")
|
||||
# root "posts#index"
|
||||
root "joints#index"
|
||||
end
|
||||
|
||||
Binary file not shown.
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the "{}" from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
@@ -0,0 +1,7 @@
|
||||
require "test_helper"
|
||||
|
||||
class JointsDashboardTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user