With rain comes the rainbow, and there’s always a pot of gold at the end…
I built my first content management site using Sinatra that allows users to manage “Golden Goals,” which are goals that the user hopes to accomplish throughout their life. I started my project completely ready to hit the ground running but I ran into an ultimate bugs that took me longer than I would like to admit to get rid of. Before starting my project, we had a week off for the holidays and I decided to practice and learn another programming language, Python. I had to download and install other programs to execute python code, and it all was going smooth with the new language. However, when it became time for me to start my project using ruby and Sinatra, I could not for the life of me run “rake db:migrate.” I would get upwards of 1000 lines of code telling me absolutely nothing about why it wasn’t working, but instead a message saying that I might be experiencing a bug in the ruby code. Migrations are an important part to using ruby and Sinatra that allow for the creation of active record associations, needed to connect my users to their goals. I tried everything from reinstalling my development environment, deleted all the programs I downloaded associated with python, fresh install of Mac OS on an external hard drive, etc. I refused to give up despite how long I been at it.
… eventually, after an extended amount of time, I noticed that the version sqlite3 gem that was running was not the version specified in the my gem file. Additionally, when I tried to directly uninstall the wrong version and install the correct version, I was told it wasn’t installed on the uninstall and get errors on the install. I eventually found a solution on stackoverflow that allowed to run rake db:migrate — “gem install sqlite3 — — with-sqlite3-lib=/usr/lib, ” which I initially didn’t understand. I talked to my instructor and it allowed me to install sqlite in the root of my computer, where ruby is also installed, so I could now have sqlite3 run with ruby and not listen to python or any other program that might be messing with it. With that finally out of the way, it was off to the races!
I created my migration began working on my controller and views, which weren’t too hard since already had an idea of how I wanted my site to work. I already most of that code prepared but I couldn’t test anything because I couldn’t run my migration. I had my belongs_to and has_many association in addition to my attributes in the tables for the goals and users. When I was testing my code, I wasn’t able to make my goals belong to users. It was because I forgot to include a user_id into the table for my goals. I did that and the associations were complete. I moved on to my restful routes to ensure that my url routes made sense compare to what the user would be doing on the page. Once I got the site to behave exactly how I wanted, I was almost done but not quite. I think wanted my site to look a certain way, but html and css were a something of a struggle. I know what I wanted but getting the css and html to look how I wanted was whole a whole ‘nother can of worms. With the help of the interwebs, I was able to my website to look like I wanted, not exactly but essentially.
My golden goal was to complete this project in timely manner, particularly after the long start, and I made it there! With my Golden Goals site up, I was able to set a new golden goal: learning Ruby on Rails and catching up with the rest of my cohort. When you accomplish your golden goals, you will find the gold medal at the end of the rainbow that came with the storm of struggle! Don’t give up on your goals but continue to strive to be your best self! You will make it when you remind yourself what you’re striving for!