Yet Another Coding Blog


Displaying Errors in your React/Redux Frontend Web App

Every coder knows there are millions of ways to solve a problem. Turns out, that’s just as true when it comes to figuring out what to do with the problems themselves–meaning errors. There are many different ways to display errors to users in your frontend React application, but I’m going to walk you through the way it worked for me.


Handling AJAX Errors with Vanilla JS

For my Front-End Web Programming final project, I decided to create a word game. The basic premise of the game is that the user is given a rule with which to follow, and tries to guess as many words as they can that follow that rule (e.g. words that start with “s” and end with “w”). In order to do this, I created both a Rails-backed API in which to store the games, rounds, and words that were guessed by the user, as well as the frontend that the user interacts with. Throughout the three rounds of the game, the user will try to guess as many words that follow the rule in order to gain as many points as possible. Once a user submits a word, the Rails backend performs some internal checks to ensure the word follows the rule, and calls the Merriam Webster API to make sure the word actually exists in the English language. When a user guesses a valid word, that word appears on the screen along with its point value, which is calculated based on the rules of Scrabble.


Learn to Walk Before you Run... Code

The most important lesson I learned in my Rails final project? Learn to walk before you run.


The Magic of ActiveRecord

In the final project for the Sinatra section, I decided to create a Recipe Manager app for users to be able to create, view, update and delete recipes. Obviously, one key component to such an app would be the ability to create and edit ingredients. Instead of making this a simple textarea field where a user lists all their ingredients which are then stored within the recipes table, I decided to create a separate table, and therefore a separate model for Ingredients. The alternative seemed messy and less flexible; what if I wanted to allow users to see a list of recipes for which chicken was an ingredient? That would require parsing through each recipe’s ingredients attribute and selecting any that had the word “chicken” in it, which didn’t feel quite right.


Pay VERY Close Attention to the Data Types of Your Return Values

Last week, I completed the ORMs and ActiveRecord portion of the Flatiron curriculum. It was a heavy subject with a lot of material, so rather than continue with the next session I decided to take a break from the curriculum and practice what I had learned in that section. I created a Blog CLI with ActiveRecord models and migrations, and in order to test it I tried to seed my database with instances of Users, Posts, and Comments.