Beer Recipe App

Posted by Nolan Hughes on April 16th, 2018

I built this web app using Rails and it is all about making beer recipes for home brewing. It allows users who create an account to make a recipe and view all of the other recipes that other users have created. While creating these recipes the user has the ability to select a number of fermentables, hops, and yeasts, create their own ingredients, and afterwards view, edit, and delete their recipes. I also implemented features that display the most popular style of beer and output a list of beers that only have one type of malt and hop (SMASH beers).

Throughout this process I honed my skills at making forms, views, helpers, and associations. I built out my own methods to assign attributes to join tables and it seemed like my knowledge increased ten-fold on everything I had learned up to this point. Below I’m going to go into more details about forms and refactoring along with a few of my struggles and high moments.

Forms

These were quite tricky for me at first. I knew how to use most of the Rails helpers like form_for and fields_for, but hadn’t implemented them in ways that were quite as complex as I needed for this project. I needed to be able to have the user select a current ingredient or create a new one and create an instance of a join table that assigns the ingredient to the current recipe. This is complicated because if an ingredient hasn’t been created yet I can’t use strong params to automatically create the instance of the join table and assign all of the necessary attributes to it. I had to wait until after the recipe had been saved to the database, which officially saves the ingredient, and then create and assign everything necessary for the join table instance to work.

Big shout out to Katie Larson for helping me work this problem out! She helped me work through some of the big hurdles necessary to write the custom methods that would send all of the data from the form into my methods. After that bridge was crossed I did some fine tweaking and all of the creating and assigning worked beautifully.

Refactoring

Refactoring seemed like it was going to be a chore when I started it. After giving myself a refresher on partials and helper methods though, it was a breeze! I was able to cut the amount of lines of code in my main recipe form by half with the use of helpers and divvying out code into partials. This was definitely one of the more rewarding experiences since I was able to make my code more DRY.

Conclusion

Overall, I really enjoyed working on this project and hope to increase its functionality in the future. This is definitely pertinent because of the upcoming JavaScript module. I’m getting excited already thinking of all the features that I’m going to implement.