/entabeni_demo

Showing a Rails app that creates Users with CSV Post and displays Users with GraphQL

Primary LanguageRuby

README

This README documents the steps necessary to get the application up and running, or visit the:

Live demo on Heroku

Live GraphiQL Editor

  • Ruby version: 2.6.6 (I use rbenv)

  • Rails version: 6.0.3

  • System dependencies: PostgreSQL (brew install postgresql)

  • Configuration: bundle install && yarn install

  • Local database creation: PostgreSQL create entabeni_demo with user and password created
    Same creds added to development environment using Rails 6 custom credentials.
    Edited with rails credentials:edit --environment development

postgres:
  user: yourname
  password: supersecret

Note: There is an issue deploying on Heroku with this new Rails 6 syntax (for environment-specific encrypted credentials) in the database.yml file, so it is removed prior to deployment:

  username: <%= Rails.application.credentials.postgres[:user] %>
  password: <%= Rails.application.credentials.postgres[:password] %>
  • Local database initialization:
rails db:create db:migrate db:seed
  • How to run the test suite:
    - bundle exec rspec

  • Deployment instructions:
    - modify main branch
    - push to remote heroku (uses puma via Procfile)

  • Create Users with CSV file
    - upload button available at app home page
    - format expected (in any order) with valid US phones and emails:

First,Last,Phone,Email
Bob,Jones,360.599.2221,bobjones@jones.com
Roger,Daltry,360-599-2224,rogerdaltry@daltry.com
Susan,Smith,(360) 599-2225,mrssmith@grannysmith.com
Floy,Ella,360.599.2223,floyella@memorials.com
  • Screenshots of working demo:

GraphiQL query of all Users on Heroku (try yourself):

Showing the GraphQL custom scalar that formats phones on Query result:

Imported CSV segregating data (using ActiveRecord validation) and returning errors to user: CSV Form validation

Same result on Heroku (try yourself):

After db:seed on Heroku Postgres instance (Lood asked if I had dealt with multi-tenancy. The better answer is yes, as a client, not the host):

The result of imported data (3 valid records from example at bottom) combined with seed data on Heroku Postgres instance: