My Sinatra App, Rummage

Posted by warrend on February 13, 2017

I live in Park Slope (Brooklyn) where people leave items on the street all the time. Some of the items are worth something — old records, CDs, while others, not so much. Countless times I’ve seen used potty training toilets, crumbling furniture, or old shoes with a “free!” sign on them. Nevertheless, I believe the practice of sharing and hand-me-downs is a societal good, so I decided to build a Sinatra app that allows people to post and find items on the street. I’m sure something similar exists, but it was a good learning exercise.

I have three models in my app — users, items, and tags. Tags are categories, but I was concerned about ActiveRecord being able to pluralize the word category, so I chose to use tags instead.

First I drew out my models and their associations on paper. I’m a visual learner, so it helps to draw boxes with arrows and diagrams for an app, otherwise everything seems a little too conceptual. In the app, users have many items, items have a user and a tag, and tags have many items.

The app went smoother than expected, but I had some trouble pushing items into the tag model. I wanted the user to be able to click on a tag and see all of the related items. I finally got it working after some back and forth and some help with my friend @adamfriedl. I’m still a little hazy about form names and when to use:

name=“item[name]”

verses

name=“name”

I made sure I started from scratch on this project. Instead of copying and pasting an existing app, I build the structure from the ground up. This helped me to really understand all of its components.

Finally, I added in some minor CSS using materializecss.com.

You can check out the app here.