Just showing a simple way to connect to a DB with ruby
(this app was made in like 15 min so don't mind)
At your terminal, run:
$ gem install activerecord
$ gem install sqlite3
To create the database tables, run:
$ ruby create_database.rb
To create the records, run:
$ ruby create_records.rb
To run your query, run:
$ ruby main.rb