My 2nd Project: Outcast

A web application I created using the Sinatra library and Active Record’s awesome database capabilities — here’s how I did it

Victor Williams
3 min readAug 23, 2020

Going into my second portfolio project build, I wanted to remain consistent with my passions but I needed to challenge myself in how I visualized the things I wanted to create. Before I started, I thought I could just build on my previous CLI (command-line interface) project but I knew I needed to slow down and take much-needed time hauling through all the Object Relational Mapping and Active Record fundamentals I had only glanced over previously. Because of the (long and sometimes boring) work I put into relearning the basics, I was able to build an MVP (Minimum Viable Product) for my Sinatra-based project. Here are some takeaways from that experience:

Active Record & What It Does

Active Record is what makes the creation and implementation of data, and the logic for that data, storable to a database. What that means is that without Active Record, it would be much harder to create and store information. If you’ve seen even a second of Netflix’s documentary on Cambridge Analytica, you’d know how important your data is to big tech companies and the surveillance State.

In a less dystopian way, Active Record is responsible for cookies and sessions that work to store your information and browsing activity on a web app. It also knows if the credentials you entered are actually the credentials of an account that exists on that website and keeps you signed in even after you leave the page.

To top it off, Active Record comes with some really cool features that cut down the amount of code you need to use when establishing associations between your Models:

class User < ActiveRecord::Base    has_many :posts     # establishes the associations   has_secure_password # bcrypt macroendclass Post < ActiveRecord::Base    belongs_to :user    # active record validators below 

validates :title, :image_url, :description, presence: true
end

I established an association between my User and Post classes without having to do the work of initializing and creating class methods as you normally do in Ruby.

Okay, I know what Active Records is — now what?

Now we can get into the good stuff! I’ll explain some key takeaways from my experience.

Ideate

Think of something you’re passionate about and won’t burn out on too fast — you’ll need to trust that you made the right decision when it’s time to do the coding. For me, this was a program where users could create spaces to engage with one another, but it doesn’t have to be that for you.

Wireframing

Write down your models, their attributes, and associations. Staying organized is a must; there are a lot of files in a lot of folders and you’ll need to make sure to know how each piece relates to the other. If you don’t you’ll end up feeling like this:

Test your Models & associations

You can do this step in the console by creating seed data and adjusting your migrations as needed. You can create migrations using rake db:migrate! Here’s a general outline of how I did mine:

vic = User.create(pass in model attributes and their values)Post.create(pass in post model attributes and their values)

Generally, the main takeaway from my project building experience is this: build your MVC actions based on the flow of your app — not the flow of what you think your app should be — one short and easy step at a time, making sure to test as you go. This is very doable and you are very capable.

Also, here’s how Outcast turned out! Happy coding!

--

--

Victor Williams

Software Engineering student. “God gives nothing to those who keep their arms crossed.”