Sinatra Project
Our challenge this week was to build a web app using what we had learned about Sinatra and ActiveRecord.
It was pretty straightforward: Build an app that allows you to organize something via forms and a database.
I decided to build an app to create and organize recipes but to utilize the LCARS system. LCARS stands for Library Computer Access/Retrieval System and was created by Michael Okuda for the Star Trek tv series.
The skeleton of the app was fairly easy. Through the course of the lessons leading up to it we had pretty much already built the app. There was just a few couple of things that I found challenging.
Challenge One: LCARS
I knew what I wanted to do but not how to do it. So began the research. There being many Star Trek fans there where also many ways of going about this. The most straight forward was using HTML and CSS. The problem: We hadn't learned much about either of those yet. Through days of reading everything I could and experimenting with CSS frameworks I was able to take pieces from different sources and put them together into a functional replica of the LCARS system.
Challenge Two: Error Messages
As an bonus challenge we where asked to include error messages in our web app. Also something we hadn't really learned much about yet.
First I wanted to have an error message that would display if the forms where left blank when submitting. I learned, in this program, errors are automatically stored into a hash and displaying them was just a matter of accessing that. I used .any? to iterate over the errors hash and check to see if there was anything in it for the current user. If there was the I used .full_message which would display the full message and .each to display each on in turn.
Next I wanted to have an error that would display if someone tried to by pass the login screen. This one I want with a large red alert screen that would display a flashing red alert symbol. I used CSS and HTML for this in it's own view and simply used logged_in? and an if statement to redirect to the error page if someone was not logged in.
Comments
Post a Comment