Crate Digger

Ryan Schleck
3 min readJul 20, 2021

--

For my phase 3 project I created an app I affectionately call “crate digger”. I have been learning the ins and outs of the Ruby On Rails framework and find it’s ease and speed far exceed my previous experiences with the Sinatra framework. Aside from all of the handy generators rails comes with that allow you to create models, views, and controllers it comes packed with features such as Action::View helpers and FormBuilders (my personal favorite) which make quick coding a breeze. Also the ability to render forms or any criteria for that matter through the use of partials keeps your code DRY (don’t repeat yourself). With all of these tools at my fingertips I felt ready to create the coolest app for my phase 3 project…a record store review site.

For this I needed to be able to seed my database with a bunch of record stores, which sounds like the perfect excuse to utilize the yelp API. This API would allow me to receive JSON data relating to record stores that I would use to build store models in my app. This API required authentication through the use of a secret id/key pair. I would need to make sure that I didn’t accidentally push my secret id/key pair to github so I used the familiar gem dotenv from my last project. I also wanted users to be able to login and keep their information secure so I opted to use the bcrypt gem. Sometimes though you just don’t want to have to remember a username and password…wouldn’t it be nice if you could sign in with just a click of a button through a service you were familiar with? What about google? well thanks to omniauth my app can do just that! Now I get to talk about the fun part of this project…the data!

Just a great record you could find at one of the hundreds of stores listed on my project site.

I first scraped a website for a list of states and their abbreviations cause…I wasn’t typing all that out. I used this data to build each state in my state class. A state has_many cities and a city belongs_to a state. I sadly had to type out the name of each city I wanted to include in my app. I kind of got ambitious with this and got…basically all the most populated cities in the united states. I then wanted to have a list of every single zip code for every single city I typed out. Well that seemed impossible…cause I’m too lazy to type all of that, but I managed to find a site that listed every zip code for a city and state that were within its url params and viola! I scraped every single zip code for the cities. I used these zip codes to associate the stores I built models for with existing cities based on their zip codes. I never wanted to have a store that was not associated with a city…because a city has_many stores and a store belongs_to a city.

It has been a journey but I am very satisfied with the outcome. I’ve created an app with over 12 hundred record stores listed, pictures and addresses and phone numbers for all of them. Even store hours for a few! I’m hoping to actually deploy this site once I clean up how it looks a bit.

--

--