Building a Road Trip Planner from Scratch with Ruby on Rails

Photo: Unsplash/averie woodard

4/22/21

Day 1 | Ahh, project-planning time. After getting through the Rails section of the Flatiron School program, it’s time to build another portfolio project—this time using Ruby on Rails.

For my project I’m building a minimalist food-focused road trip planner called A Day Away. Through the web app, a user can sign up and log in with a third-party provider like Google to create different trip itineraries, which include destinations (think city, state) and restaurants in each destination. [NOTE: this changed later.]

This way, a user can build and have access to simplified lists of restaurants, diners, and food markets in each itinerary. On the site, users will be able to see all the trip itineraries.

I spent most of the day drawing out my web in the Sketch app.

Now, I have a rough outline of my objects, associated data, and nesting routes.

The plan for tomorrow, which is the very first day of actual coding, is to get my signup and login pages working with Omniauth.

I’m off to a good start. I’m not sure how I’ll fare but I remember feeling like this — 75 percent uncertain — at the beginning of my Sinatra portfolio project process and submitting my project feeling super confident.

Total hours planning: ~ 10 hours

Photo: Unsplash/Robert Bye

4/23/21

Day 2| Good morning. I’m feeling good about starting. Right now, I’m working on my associations between my objects in the project, which are my User, Itinerary, Destination (city, state), and Eatery models.

I’m writing out my relationships and trying to figure out whether I need a separate join table OR if an object can act as my join table.

I drew out this Lucid Table prior to starting and not sure if I actually want a ItineraryDestinations table. I’m going to write out my models and relationships and list out the methods I anticipate needing.

4/24/2021

Day 3 | Greetings from the third day working on this project. I’ve spent most of the last two days getting my scraper class to work following this amazing guide (thank you!).

Since I have such complex relationships in place, it took a long time to successfully scrape and create objects with the correct associations in place. I decided it was important for me to have real data in place to work with instead of fake data.

It’s much more appealing to me to look at real data and work out the kinks of eliminating repeat data. I believe I have everything in place for the 9 sample itineraries I’ll have on my website.

Total hours worked — at least 12+ hours. I’ve been dreaming about Rails.

Photo: Unsplash/Kris Atomic

4/25/2021

DAY 4 | It’s funny how you start the project process thinking you know absolutely nothing about Rails or whatever language you’re learning and then when you’re forced to sit down and start coding you know exactly what to Google to put pen to paper.

On the agenda today is adding the has_secure_password method back to my User model since I had removed it to enable the Facebook Omniauth login, which requires the User have an email, uid, and image.

I removed it thinking my User models would break but I don’t think that was necessary at all. The Omniauth login is working (yay!). I’m going to watch another review video about Omniauth process so the token-switching system is more clear. I think I’ll write a post breaking down the process—shoutout to all the super-helpful people who have added code guides on Medium (::claps::).

I’m in a good headspace today —I’m grateful to be learning so much. The last few days, I’ve been down in the dumps with a complete lack of confidence about Rails. It’s definitely getting better now that I’m working and revisiting video tutorials and find that I actually remember the foundations. Huzzah.

4/27/2021

DAY 5 + 6 | Hello from day 6. I missed my update yesterday. I was at a roadblock trying to build a nested form for my complex associations.

At the beginning of the day, I wasn’t sure whether I could build a triple nested form with an infinite number of entries submitted by the user. At the end of the day, it was clear that was impossible, after hours of reading examples of triple nested forms (ex: Show has_many Seasons, which has_many Episodes.)

That’s because Rails’ form builder methods need an object to wrap around, it’s required to instantiate an object in the controller to pass to the form in the view.

To triple check that I couldn’t write out a form the way I intended with the user’s capability to add an infinite number of destinations and eateries to hit up along the way, I asked the educational tech coach last night during a scheduled Rails Study Group/Project Q&A session. Confirmation acquired.

So it was back to the drawing board. I had to rewrite my relationships to enable a nested form that was possible. (I’m eager to get to Redux, React, and Javascript to solve this problem.)

My object relationships before.

Here’s what my object relationships are currently:

Now, I only have one join table between Trips and Eateries. I removed the Destinations object, which held city and state attributes, and moved that info to Eateries. Now I can build a nested form with Trip, which has many Eateries. I will need to pass the form a finite number of eateries for the user to fill out. I will probably let them build out 5 of them for ease. It’s not the best solution but my hands are tied with what I know so far and the program deadline looming closer.

So it’s back to work for me. I’ve been coding all day and night until at least 9 p.m. — a solid 12-hour day every day. I’ve been learning a ton of Rails fundamentals by debugging and Googling stuff along the way.

I feel like I’ve filled in so many learning gaps in the last week.

One thing I’m super proud of so far is building a scraper to seed the web app with real data. I’ve had to tweak the scraper and its connections within the app so many times, I’ve gotten really good practice with scraping and file integration. Just super proud of myself that it works. At the end of the day, coding is all about the small wins and little bits of wisdom gained.

I think it looks pretty okay for a lack of CSS so far.

On the trips/index, there’s a list of itineraries made from data scrapped from Roadfoods.com. On the show page, you can see the list of eateries along the route.

I’m hoping to get rest of the web app working today including all the new and edit forms for objects.

What’s working so far: My signup, login, sign in with Facebook through Omniauth, and logout processes — plus my scraper for seed data.

Photo: Unsplash/ Lucian Dachman

4/29/21

Hello from Day 8 of working on this Rails project. I’ll probably be able to submit my project later tonight. I’m eager to pass my project assessment and get rolling with Javascript.

Overall, it’s been a great experience. I’m as tired as I was after completing my Sinatra project.

If I could give myself any advice for the next project section it would be to not overcomplicate things. For this road trips planner, I started off with a mess of associations and TWO complicated join tables. It was all too much to manage for my first build.

My next mistake was designing the form that would create Trips — and every other connected object with it — without a full understanding of nested forms and what was necessary to create a dynamic, triple nested form. I spent a full day Googling and reading Stack Overflow solutions before realizing the dynamic nature I was planning for was not possible without JS and/or gems that would complicate my app far beyond my current capability.

For the next chapter of my coding journey, I solemnly swear — mostly for my own sanity — to simplify things and stick with the project requirements. And understand necessary concepts before the design phase. Though, I learned a ton about forms and connected objects from this dilemma.

Overall, I’d say this project has taught me the most so far about the debugging and research process. I was able to code most of the project without help — only Googling and looking at Stack Overflow almost at every step.

Thanks for reading!

--

--

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