Coding Bootcamp: Week Two (Cheat Sheets)

The conclusion of another week has come and gone in my Firehose journey to becoming a software developer. In full disclosure, my second week was definitely my most challenging week of learning to code to date. The reason for my struggle was probably self-induced, but it definitely tested my patience and my problem-solving ability! It all started with this error:

CodingError

When I first received this error I was a little confused, but it wasn’t the first time I had left out a comma or misplaced a colon in my lines of code. So, I was optimistic about resolving my issue and set out to find a solution via coder’s best friend, Mr. Google. After running a few searches and finding several combinations of resolutions, I decided to try a few that seemed more geared to what my problem seemed to be, which was highlighted in bright red: “ActiveModel::UnknownAttributeError in PlacesController#create – unknown attribute ‘user_id’ for Place.”

If this were me a few weeks ago, well, then I probably would have shut off my computer and cried a little bit. How could I possibly understand what this error is telling me to do? Luckily, even though I was new to this programming field I was actually learning. It may seem like I am missing a lot of what is happening while learning to code new features and build new apps, but I was actually picking up a lot of the things and understanding how they work. This helped me a great deal because it allowed me to ask the right question to solve my issue. Unfortunately for me, the solutions I tried did not solve my issue and led to my frustrating week!

To shorten up my story and to shine some light on the resolution I will simply give a quick summary of my trial and error. Basically, the error was telling me that there was no place for the action being called to store the information I was requesting. This was because I did not have a column in my database to store user_id information when creating a new Place. I know that most of you may not understand what I am talking about so I will try to give you an analogy:

Imagine that you are watching and cooking alongside a cooking show. You are creating a beautiful dish, which is being laid out by your instructor (a famous chef), and you were told before the show that you needed explicit ingredients to help you make this particular dish. Now, the chef requests a specific ingredient to be used at a specific moment in the cooking process, but you forgot to purchase this item from the grocery store. Unfortunately, this ingredient makes the whole dish and without that particular item, the entire meal just does not work. That is similar to the index in coding.

For whatever reason, my index did not have the right “ingredient” for my code to function properly because I was missing a column that would allow the information to be stored for an action being called. Eventually, I was able to get a solution that alleviated my troubles.

The solution was centered around three simple commands:

  1. bundle exec rake db:drop
  2. bundle exec rake db:create
  3. bundle exec rake db:migrate

Viola!! There is my application in all of its glory and working like a charm! Amazing what a few small and simple commands will do for you.

wb52

So, I wrote all of that to tell you that I will begin keeping my own “cheat sheet.” Basically, it is a list of commands that will help me to solve issues as I continue to build new features. I plan on creating cheat sheets for particular programs, such as Github, Heroku, the command line, Ruby on Rails, Javascript, and CSS. It is a general practice amongst developers to have their own index of commands and definitions to help them complete a project. Simply put, it is a habit that I hope to pick up early to help be more efficient and hopefully helps me evade future frustrations that have easy fixes!

Till next time!

-Nick

 

Advertisements

One thought on “Coding Bootcamp: Week Two (Cheat Sheets)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s