Story Of a Small Blog

Ronny Toribio Blanco
3 min readJan 18, 2021

For a month now, my classmates and I have been learning and working on SQL and ActiveRecord. When I first started working with SQL, I did not favor it. Compared to a well-known programming language like ruby or python, it felt useless. After some time, I realized the magic of being able to categorize and store data. As you could imagine, this made me want to start working on my next project. The project would be to create a web app using Sinatra and ActiveRecord. This app would create, update, and delete information through a process called CRUD. After a lot of thought, I decided that the best way to show off the CRUD functionally would be to make a simple blog.

To find the purpose of my app, I began to free-write. I grabbed a piece of paper and a pen and started writing down all my ideas. This process ultimately helped me create a course of action. From the beginning, I knew I was going to have users and allow them to have blogs. I designed a “Users” table that would have a username, name, and password. My next step was to create the posts table that would take in a user ID to associate the two. After I correctly migrated my tables, I then started to work on the models themselves. I made it so that the user will have a self-referential relationship with itself, that way one user will be able to follow another user. That led me to create another migration, this time a join migration called follows and another modal associated with it. After testing my modals associations with one another, I started to work on the controllers and views of my application.

I first created three controller objects. The first controller object for users. The second for blogs/posts. The final one for registration, logins, and where my helper methods would reside. Since I was already familiar with python’s Flask framework, Sinatra routes were extremely easy to work with. After I created all the proper “get” routes, I started to develop all the need “post”, “patch”, and “delete” routes. Luckily, when I was creating all the “get” routes I also developed their associated “erb” files and gave them proper forms inside of them. This process made it easier to implement the post, patch, and delete routes as I already knew exactly how my params hash would look like.

The part that was most difficult but also not required for my project was styling my application. Many will turn in their projects once all the requirements have been met. The problem with that is that it encourages laziness and also negates the possibility of further learning. Luckily I counted it as a requirement and started to stylize my application. Styling my application led me to fully understand how to use a front-end framework called Bootstrap that I have used before but didn’t understand quite yet. I also learned the importance of developing for all forms of display like mobile browsers, being that more users tend to use the web on their phones than they do on their computers.

Even though working with Sinatra didn’t feel like something new, this project taught me a lot about the importance of having a proper database and having the ability to talk to it. I learned how many known applications/websites share a common theme of Model-view-controller, better known as MVC, and the importance of understanding your preferred programming language’s best ORM, also known as Object Relational Mapper.

--

--