DEV Community

Bianca Charlotin
Bianca Charlotin

Posted on

Sinatra Web APP

This blog post will be discussing the process of completing my second flatiron coding project. It will go into detail on the project I created and the difficulties I encountered.

This project focused on using Sinatra (which is an alternative to other Ruby web application frameworks such as Ruby on Rails) and developing a web application. As soon I heard the word "web application" my mind went to the many social media sites I've encountered. So it was then that I decided that I would be building the inner workings of a social media site( currently this is nowhere near a fully functional social media site, yet).

Sinatra was an eye-opener to the world of servers, ULR's, GET and POST requests, etc. Working with Sinatra also help to fortify my attention to detail, specifically when it came to creating forms (in HTML using erb files). While making forms it was important to make sure we understood the name attribute in those forms, so that we could collect users' input on the back end. Essentially, grasping all of this new information and applying it to our labs was difficult and tedious.

This project consisted of building Models, Controllers, and Views.
Models are where I created my objects( Users, and Posts) with that I had to establish their relationship (belongs to, has many, etc.) because that would determine where my foreign-key would go or if I need a Join table. Then I created my tables for my database (all done using Active records).

Next, I used my controllers to handle the GET and POST request from the URL. Also within my controller was the majority of my Ruby code, so I had to:
Validate the uniqueness of the user login attribute (username or email).
Ensure that the user was signed in and can view certain view pages
Ensure that users can edit and delete only their own resources - not resources created by other users.
create my objects so that I may access them on my view. fils (AKA HTML/erb files)
and much more...
In conjunction with my controller actions, I had to build corresponding Views. This is where the HTML and some minor ruby code would go (Fun Fact: erb files allow you to uses ruby code inside HTML). The View is also what the user will be interacting with, and inputting data for us to collect in our controllers.

End Result:
I created the beginnings of a social media site called The Hive, where users are able to:

Sign Up
Login
Logout
Create, Edit, or Delete Post
(hope to add more features like a profile View, and add some CSS. to provide for a better UX experience )

Link to my GitHub coming soon.
Alt Text

Top comments (1)

Collapse
 
cescquintero profile image
Francisco Quintero 🇨🇴

Good effort. It's nice you're learning with Sinatra as you'll be able to see everything that goes behind the scenes in regular web app.s