diff --git a/app/controllers/joints_controller.rb b/app/controllers/joints_controller.rb new file mode 100644 index 0000000..7d8eb74 --- /dev/null +++ b/app/controllers/joints_controller.rb @@ -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 diff --git a/app/models/joints_dashboard.rb b/app/models/joints_dashboard.rb new file mode 100644 index 0000000..b8e8213 --- /dev/null +++ b/app/models/joints_dashboard.rb @@ -0,0 +1,10 @@ +class JointsDashboard < ApplicationRecord + self.table_name = "Joints" + + # Prevent actidental updates from code: + def readonly? + true + end + + +end diff --git a/app/views/joints/joints.html.erb b/app/views/joints/joints.html.erb new file mode 100644 index 0000000..7b2b2eb --- /dev/null +++ b/app/views/joints/joints.html.erb @@ -0,0 +1,39 @@ +

Excel Replacement Dashboard

+ + +<%= form_with url: dashboard_path, method: :get, local: true do |f| %> +
+ <%= f.label :category, "Select Category:" %> + <%= f.select :category, options_for_select(@available_categories, params[:category]), include_blank: "All Categories" %> +
+ +
+ <%= f.label :region, "Select Region:" %> + <%= f.select :region, options_for_select(@available_regions, params[:region]), include_blank: "All Regions" %> +
+ + <%= f.submit "Filter Data" %> +<% end %> + +
+ + +

Dashboard Results

+ + + + + + + + + + <% @records.each do |record| %> + + + + + + <% end %> + +
Column 1Column 2Value
<%= record.category_column %><%= record.region_column %><%= record.metric_value_column %>
diff --git a/config/application.rb b/config/application.rb index 72c6ba0..da8a7af 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/config/database.yml b/config/database.yml index 302d638..7dbd3f4 100644 --- a/config/database.yml +++ b/config/database.yml @@ -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". diff --git a/config/environments/development.rb b/config/environments/development.rb index 75243c3..9cdb78c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 48254e8..39035e2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,4 +11,5 @@ Rails.application.routes.draw do # Defines the root path route ("/") # root "posts#index" + root "joints#index" end diff --git a/db/anat_proj.db b/db/anat_proj.db new file mode 100644 index 0000000..3d6847c Binary files /dev/null and b/db/anat_proj.db differ diff --git a/test/fixtures/joints_dashboards.yml b/test/fixtures/joints_dashboards.yml new file mode 100644 index 0000000..d7a3329 --- /dev/null +++ b/test/fixtures/joints_dashboards.yml @@ -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 diff --git a/test/models/joints_dashboard_test.rb b/test/models/joints_dashboard_test.rb new file mode 100644 index 0000000..afa550a --- /dev/null +++ b/test/models/joints_dashboard_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class JointsDashboardTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end