When InStock was OutOfStock: My First Rails App!

Image for post
Image for post
My First Rails Application: OutOfStock!

For our Mod 2 final project, we were tasked with creating our own Ruby on Rails application. So with the current state of the world in mind, I came up with the idea for OutOfStock! OutOfStock is a web service that uses data provided by users to keep track of products that may be out of stock at your local Seattle grocery stores. It allows you to log in, save and edit your account securely. Once logged in you can see all grocery stores and their distances from your address as well as what products other users have found to be missing from each location. You can also keep track of your grocery visits and help notify others in the area about missing products. Additionally, you can notify others who went to the same store as you at the same time when you get sick!

I had a LOT of fun making this one! Unlike the CLI app which was not a super fun user interface to work with, I could actually envision this product being used! And it is relevant to what we need today. Below are a few parts of the design that I am proud of:

1. COVID Notify

This was going to be my moneymaker! I wanted users to be able to notify others when they got sick! This way, anyone who went to the same store at the same time would know that they may have come in contact with someone who is now sick.

Initially, I was thinking there would be contact information set up with each user. Perhaps an email and then I could email every user. So first, I set out to get a list of emails of everyone that the sick user would have potentially come into contact with. Then I had a list of users to contact. Now what?

I looked into the email feature in rails and I was instantly confused. Setting up an email blast would take a bit of work and learning this new feature. But also, who wants their inbox cluttered with more emails? Hmmm.. maybe there’s a different way to do this…

And there was! Notifications!! It made perfect sense. When a user logs in they should see a little notification about the potential contact with COVID and then be able to dismiss it! So that’s exactly what I did. I added a user attribute that keeps track of who needs to be notified and about which date. Once they have seen the note, they can click a button and poof, it’s gone!

2. Missing Item Restock

When developing this app, I focused a lot of planning and energy into tracking which items were missing at which stores. Using join tables and proper associations I was really happy when users were able to select which items were missing during their grocery store visit and have that data be available to all other users. Yay! But I completely forgot about restocking! In real life, because a product was missing on a certain date does not mean it will be gone forever! I needed a way to model restocking.

My solution was to only keep missing items as out of stock for 7 days. This means that my database clears any reports of items missing that are more than 7 days old. This was a quick and easy fix and was reasonable for my time constraints. This method for restocking will depend on users with good participation for accurate data. If users continue to flag items as missing then they will remain out of stock.

Ideally going forward however, either grocery stores themselves or other users would be able to note when items come back into stock.

3. Admin Account

The grocery stores are added to the database on the backend. I seeded that data manually. I figured users should not have the ability to add grocery stores. It would be very hard to keep track of the data if they were! But as an afterthought, I decided to include an Admin Account. This admin account would have special access and would be able to add grocery stores when they log in.

To allow this, I created a new form and then I had to decide how to authorize certain accounts access to this form. At first I used the user id in the database. This was a very bad idea… As soon as I reset my database, everything broke! My app was suddenly reliant on certain user ids for certain pages. This was not good. So, I went back and did what I should have done in the first place. I added an admin column to my users and set it to a datatype of boolean. This made much more sense. Now on the backend I could set the admin users and this allowed them to access the form. Normal users would be guided to choose from an existing grocery store only.

Ideally, I would have also added the ability to add new items that could be out of stock to admin accounts.

Naming it OutOfStock

Why is it called OutOfStock? I was going to name my project InStock. It made sense, the application will let people know what is InStock. Though I figured I should google the name to see if it exists first… Turns out InStock does already exist! And with the same idea and concept as mine!! What were the chances! (pretty high given we are all in this pandemic together). Though after downloading my competitions app I do see that my COVID Notify feature is unique! So take that!

It turned out I was about two weeks too late for my million dollar idea. But that’s all right, we will just have to wait for my next one.

I love seafood, exploring new cities, board games and learning to love to code. https://github.com/sarakhandaker/portfolio

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store