Street Eats: A Rails Web App for Browsing Food Trucks

Behold, Street Eats

I built Street Eats as one of my portfolio projects for our Rails module at The Flatiron School. For this blog post I want to give you a quick tour of the app and my design process. To start, I mapped out the flow of the application, what models I’d need, and their associations. I used Draw.io for this.

Seed the Database and Create Migrations

For this app, I decided to manually seed my database with the most popular food trucks in Knoxville, rather than use the Yelp API. I did this for a couple of reasons. There’s a bunch of food trucks on Yelp that aren’t active and I wanted my app to provide some specific information I had to track down manually, like the link to their schedules. Once I had my top 20 food trucks in my seeds file and the information I wanted for each, I moved on to my migrations. I created tables for food trucks, reviews, and users. Once I generated those tables I ran the migrations and seeded the database.

Generate Models

Next I moved on to generating my models. I created the User model and defined it’s associations. A user has many reviews and has many food trucks through reviews. I also added validations for username and email. The food truck model has many reviews and has many users through reviews. And finally the reviews model, which is the join table, belongs to a user and belongs to a food truck. I also added validations for content and title. I didn’t want users leaving blank reviews after all!

Omniauth Strategy: Google

The first thing I wanted to do was create my log in feature. I used Omniauth to allow a user to sign in with Google. I followed the instructions and documentation here. This piece was fairly straightforward.

Set up Those Controllers

To finish the Omniauth functionality, you will need to create a Sessions controller and add a method that lets other developers know what it is you're doing. My sessions controller looks like this:

Views, Forms, and Scopes

The views was where things got tricky. I had to do a lot of debugging and byebug-ing on this project to figure out why certain forms weren’t working or why I kept getting errors. Especially when you’ve got various associations, nested resources and routes, things get complicated quick. So I started with some basic views. I need a Profile Page, aka a show page for the user, a My Reviews page, which was a show page for the reviews, and an All Food Trucks page, which was an index page of food trucks. The search feature on the index page is for querying the database and returning only food trucks that match certain params, in this case cuisine and name. I used a scope method, which is just syntactic sugar for a class method, to build out this functionality.

--

--

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
Kristin Ponsonby

Kristin Ponsonby

Software engineer and advocate for women in STEM.