Memoirs of a Jr. Dev

I struggled with this week’s post because I had so much to talk about. I voluntarily worked 10 hour days, mostly due to a broken search feature that generated an unprecedented amount of urgent bugfixes, and a busted MySQL config that had me reinstalling my OS~GAWD!
Good news? I didn’t have to do much on my end, besides spending a few hours looking for the problem, and crisis averted.

Mostly I spent this week dealing with what I have dubbed MySQ HELL. Say it 5 times fast. MySQL is basically the database server. If you have never worked on a team with real live data, MySQL might allude you for a while like it did me. By default, rails uses sqlite, you probably don’t want this, I recommend using the MySQL2 gem instead. Here is a great article from Digital Ocean that walks you through the process.
Understanding and used the gem was not my issue however. My issue existed when I kept receiving errors when trying to run the server or console to check out my awesome code. Here is what I learned.

  • If at any point your error has the word “database” in it. Guess what, you are working with no data, and as awesome as Rails is, it cannot create data out of nothing. Not yet at least.

After days and many better devs than I trying to figure it out…I learned something very valuable. Rake db:EVERYTHANG is the key to your MySQL error messages && order is important.

  • Drop, Create and Migrate. Then Seed and Scaffold. When I was in acupuncture school many moons ago, there was a guy there that had written songs, sort of like mnemonics, that helped you remember herb formulas. The music wasn’t that great, but goddamn if I didn’t have earworms when taking my state board exams that told me what herbs were contained in the formula for Spleen Qi Deficiency. I bring this up because I think I’m going to write some death metal songs about all the shit I forget to do that causes ALL my environment issues. Jaco Pretorius talks about this little/BIG task in a clear and concise way.

  • I had a great A-Ha moment this week when viewing a senior engineer’s PR and realising I had JUST read a resource about the same bug he just fixed. The bug had to do with date tags and octal. Briefly, Ruby’s Integer Class treats numbers starting with 0 as octal. So if you are using a date like 09/01/16, those leading zeros will throw a syntax error. Here is a little Pry session to explain.
    [1] pry(main)> Integer('08')
    ArgumentError: invalid value for Integer(): "08"
    from (pry):1:in `Integer'
    [2] pry(main)> '08'.to_i
    => 8

    So converting the string value of a number to an integer will allow your user to enter in a date as either “08” or “8” without breaking everything! YAY….learnin’
The classic Sesame Street 1-2-3-4-5-6-7-8-9-10-11-TWELVE!

And these were my lessons this week! Please let me know in the comments any other great ways to remember tasks you perform often, more in-depth coverage of octal and anything else you would like to share. See you next week!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.