Sinatra and MVC

For the second project at the Flatiron School’s CS course, I was tasked with producing a fully functional application using the Sinatra Domain Structured Language. Sinatra is a relatively light and agile framework and can be used to create applications quickly and as such, uses a specific patterns.

MVC

The second part of the MVC architecture is the View. A view is the front-end and, in essence, is what the user will see. View files have .erb filetype which allows for HTML and Ruby to be embedded (Embedded-RuBy). They include index.erb files which are typically used to show many objects and show.erb files which are more specific to one instance of a model.

CRUD Actions

All applications, including Sinatra, contain certain core methods for how they interact with data. An important acronym to remember is CRUD, which stands for Create, Read, Update, and Delete. These four actions represent all ways in which data can be acted upon in an application. One can create instances of a model using “get” routes, read them through “post” routes, and update or delete through their own “update” and “delete” routes.

Task Hammer Application

Another issue was that Chrome was having trouble resetting my CSS document so I couldn’t quickly test for aesthetics. This drastically slowed my work toward a more visually pleasing project.

Originally, had anticipated a “due date” with a calendar interface but the data type I used (datetime) was strict about structure of data entered. When data wasn’t entered incorrectly, the value wasn’t passed through on my index page. I also wanted to add a password validation section for the user during sign up to ensure that they didn’t mistype their initial password. These will be added during my next modifications.

Probably my favorite part of the project was wiring up the “Hammer” button for a users individual tasks. The mechanism wasn’t terribly complicated and involved a simple toggle of a boolean to mark uncompleted tasks as completed but it was nice to see the mechanism work from the user stand-point.

Using Sinatra and the more basic structure of MVC has hopefully prepared me for the next section where the same concepts are applied to Ruby on Rails, a more robust framework.

--

--

Full-Stack Software Developer- Founder of Skylark Hammocks, BEST, LLC, and several other as of yet unrealized ventures.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Seth Blanchard

Full-Stack Software Developer- Founder of Skylark Hammocks, BEST, LLC, and several other as of yet unrealized ventures.