Flatiron Sinatra Project

Mike Wilder
3 min readMar 3, 2021
Logo By Kate Godwin

As the old saying goes, time flies when you’re working hard and it flies even faster when you’re working hard during a pandemic. It feels like I started my Online Software Engineering course at Flatiron last month but some it’s been more like four and a half! For my second project I was tasked with building a rudimentary website using the Sinatra framework, a project which would require me to write in Ruby, HTML and CSS, at first it was a daunting proposition but as I began to dig into it I was surprised by how much I had learned.

My goal was to create a tool to track a user’s wine purchases, a way for people to remember what they had bought and how much(or how little) they liked it. From my time working at a wine store I know many people who could use a site exactly like it.

I first had to build my MVC(model, view, controller) architecture which was very simple with the help of Corneal, and then build out the functionality within that framework. I built classes for Users and Wines, planning on a simple system wherein Wines were assigned a foreign key to connect them to the User who recorded them. After thinking through the application and some additional functionality I might like to add I decided to use a join table, a decision that wound up causing me no small amount of consternation as I spent days with improperly formatted tables only to find a small typo lurking in my join table.

Initially my join(which is called “Tickets”) contained only a user ID and a wine ID but after talking to my cohort leader Matteo I realized that if I wanted to expand my program it would make sense to move the price and rating columns from the wine table to tickets. This would allow multiple users to record their price and impressions on the same wine without creating an entire new instance of the wine class.

Ultimately My Join Table Wound Up Looking Like This

Once I had my tables set up and my database was functioning as intended I had to flesh out the routes which would direct users around my site as well as passing data into my database. Building the controllers occasionally felt like a bit of a wild goose chase but with a good deal of determination and some very useful helper methods I was able to build a site which functioned as planned and even had some very basic security measures which protected User’s accounts from uninvited visitors.

The Helper Methods In Question

Going forward I would like to make the list of wines searchable and sortable by a variety of categories as opposed to just an alphabetical list by name in addition to making stylistic tweaks for a more aesthetically pleasing user experience.

--

--