Barbell Strawng: A Sinatra Based Web App for Weightlifters .

Posted by Johnathon Wood on March 6, 2019

My first Sinatra based web-application allows users to track their progress lifting weights. After advancing beyond beginner weightlifting routines, like Stronglift’s 5x5, and making awesome progress with Jim Wendeler’s 531 program, I decided to make my own app. Without a plan, natural intermediate weightlifters have no shot becoming advanced weightlifters, risking over training and too much volume.

Project Requirements

For this project, our applications must follow the Model View Architecture design pattern common for developing web applications. In order to save time, I used the Corneal gem to quickly generate a website template that includes a database connection and MVC directories, i.e. folders, out of the box. This gem is super useful for getting things up and running! To learn more about using corneal, click here: https://thebrianemory.github.io/corneal/

Other requirements included using at least one has_many and one belongs_to relationship. How do you figure out which one is which? Our migrations should be based on the relationship between a User and a Lift; the Users is the parent table and the Lifts is the child. Therefore, a Lift belongs to a User and a user has many Lifts. Additionally, the Lifts table will have user_id stored in its table so that we know which user is associated with which particular lift.

For the best possible explanation on how these macros work under the hood, read this entire website twice: https://guides.rubyonrails.org/association_basics.html

Simply Strong

My application focuses on a user’s bench press, deadlift, strict press, and squat.. A user can signup and create new lifts. That data is then persisted in the database so they can read it, with a get ‘lifts/:id’ request.

Error messages without technical coaches!

My first project I struggled to debug without any help. I literally spent days without making any progress at my toughest moments, staring at the same error message.

If you are coding without a partner or a tutor, my advice is simple: it will get better.

That is, your ability to clearly articulate a problem and, say, scan StackOverflow’s website to decipher which examples are helpful to your project and which won’t, will get sharper with practice. I remember being told that error messages are actually a good thing and after having built this web app on my own, I finally feel like I understand the significance of that advice. Read them carefully, and make sure you understand each part of them.

When you run learn on a Lab in the curriculum, the Capabara test-suite is like a safety net catching a trapeze artist. In order to start getting some error messages,

  1. Place a pry where inside your routes inside your controller.
  2. Run the ‘shotgun’ command inside your terminal (make sure you’ve also installed the shot gun gem inside your Gem files.)
  3. Make a specific request to the route you’re debugging. For example, if I wanted to see if a new lift was created (that is a new instance of my model), I would run shotgun and enter the IP address generated by the shotgun command, followed by the route. http://142.93.11.41:47547/lifts/new
  4. Back in your terminal, you should see that you’re in a pry session. This is where you can user ActiveRecord to create, update, and destroy instances of your model.

I also highly recommend completing as much of the Ftwitter lab as possible. It is very similar to the project, and if you can finish that lab, there is nothing stopping you from crushing this project.