Moving on and up from Sinatra

Ohletamyleta
3 min readMar 15, 2021

Start spreading the news…I’m moving to Rails…

Left: Rails app directory. Right: Sinatra app directory. One of these is simply awesome, and one is really, really amazing

After completing a Sinatra based application for my phase 2 portfolio project, I was really excited to learn about Rails. We’d spent a few months learning all about Ruby, building a CLI app, then the Sinatra one, and now, here we were. New things to learn, more features to enjoy, and so many more things to learn. SO MANY.

First off, the ability for a developer to simply enter one line of code: rails new name-of-app, and suddenly an entire complex framework just POOFs into existence in my VS code window — magic!

I really need this outfit, it looks so official.

The sheer amount of files in the window was daunting. I mean, how was I going to know what to do with all of this? How did I even get started? Where was my good old MVC setup, and how should I make new files?

Enter generators. I had a bit of a struggle with them at first (syntax will be the death of me, I swear, I’ll be taken out by a lost comma or an extra space in a 150 line html page), and I did a lot of reading. I highly recommend becoming very familiar with the documentation here, as it will answer all of your syntax and usage questions for methods and setup:

Where the Corneal gem was an excellent framework for my Sinatra adventure, what did this base Rails app model have for me? The answer ended up being 6 models, 6 controllers, and 23 view files. The ability to utilize built in functions for routes was a game changer. No more defining every single GET/POST route in detail in the controller — all it needed was one routes file, and some defined associations in my models, and there they were.

The coolest feature I was able to add was the ability for photos to be uploaded, using the gem Cloudinary and the built in Active Storage. For an excellent summary of how to make this happen, please stop by my classmate’s post here, which gives a thorough and easy to follow installation guide. Instead of using a user avatar, however, I added the images to one of my model classes. This app allows users to create cheese entries, and review them, and pair wines — and food is such a visual medium, I decided photos would be essential. The end result looks something like this:

I’m already planning a couple of other apps to construct in Rails — this one was a definite application of my learning and my wicked google skills (blog post about that coming soon), but overall it’s designed to make building apps easier, and it definitely does that!

--

--

Ohletamyleta

Software engineering grad, theatre geek, master punster.