Technical Blog


Tracking Biorhythms with Sinatra

My app doesn't yet look pretty, but I understand how it works!

I decided to build an application in Ruby's Sinatra that allows a user to track its biorhythms. If you're unfamiliar with this sort of thing, read about the basics here. In a sort of diary-esque format, a user can enter the day's physical, emotional, and intellectual states by detail and by numerical rating.

I forewent the pretty colors in the web interface to focus on understanding and developing the logic of the application. This is serious. Many validations needed to be implemented relating to preventing blank forms and inauthentic users, and the necessary logic was given to the controllers. The ability of an application to remember a logged-in user looks like magic, but it's all logically conducted by a pretty little thing called the sessions hash. This hash stores information that persists across requests, which is a miracle in the world of stateless protocol! For this app, the sessions hash was also used to display flash error messages when the user did something silly, like forgot to enter data into fields or attempted to log in without an existing account.

Understanding the under-the-hood is so important. That's why I wrote this some-would-say-mundane post about stateless protocol. To me, the way the models, views, controllers, logic, and control flow all dance and interact is as beautiful as a popping user interface.