Code Monkey home page Code Monkey logo

scouting_reports's Introduction

Scouting Reports

Scouting reports is a baseball scouting report application that allows a user to create reports for pitchers and position players.

Getting Started

Requirements

You'll need the following installed to run the application successfully:

  • Ruby 3.0 or higher
  • bundler - gem install bundler
  • Yarn - brew install yarn or Install Yarn

Initial Setup

Install the application with:

$bundle install

Seed development DB with data by running:

$rake db:seed

Run the test suite with:

$bin/rspec

Running the application

To start the server:

$rails server

Open app in the browser at URI http://localhost:3000

Discussion

To model reports, I used a newer Rails feature that was introduced in Rails 6 called Delegated Types. Delegated Types provides an alternative to Single Table Inheritance for modeling inheritance in Rails. It allows for the reports table to hold the shared data that position_reports and pitcher_reports have in common and allows the child models to have their own DB tables with their specific data attributes. This way there will not be a large shared table with many null values as there would be when using STI.

For more information on Delegated Types:

https://api.rubyonrails.org/classes/ActiveRecord/DelegatedType.html

For adding pitches on the fly in the pitcher report, I used Stimulus.js and wired up the Add Pitch button to a Stimulus controller called javascript/controllers/nested_form_controller.js.

For more information on Stimulus.js:

https://stimulus.hotwired.dev/

If I had more time, I would find a more elegant way to handle creating a new report in the UI. The way it is now, there are two buttons Create Pitcher Report and Create Position Report. The links for the buttons pass a query param for the report type to the reports controller to determine which report form to render.

Ideally, there would be one Create Report button and the correct report form fields could be generated dynamically with Javascript based on the report type select field.

I would also make the UI design look better and use Hotwire and Stimulus.js to improve the views with things like inline editing, autocomplete search fields, etc

scouting_reports's People

Contributors

zstrick avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.