Skip to content

A Ruby-on-Rails app where users can book flights for multiple passengers

Notifications You must be signed in to change notification settings

BrentBarnes/8-Bit-Flight-Booker

Repository files navigation

8-Bit Flight Booker

This is a project from the Advanced Forms and Active Record section in The Odin Project's Ruby on Rains curriculum. The original project can be found here: Flight Booker Project

Functionality

  • Book one-way flights on a specific date of August 2022 for up to four passengers
  • Associations between 4 models Airport, Flight, Passenger, Booking
  • Prepopulate drop down menus with data from multiple models
  • Usage of nested attributes (submitting to multiple models with a single click)
  • Seeding of 8 hardcoded airports and 3,400 flights using the Faker gem
  • RSpec feature tests using Capybara and FactoryBot
  • Mailer implemented for confirmation upon booking flights
  • Use of letter opener for mailer development
  • Styled using Bootstrap and custom CSS
  • Error handling (see Heroku exception)

Screenshots

Loading/Search Page

Flight Booker home page

Search Results

Flight booker search results

Passenger Information

Flight booker passenger details

Final Booking

Flight booker final booking

Mailer
When booking two passengers, it will send confirmation emails to each passenger.

Booking two passengers

First passenger email

Second passenger email

Tests

Passing tests

Local Installation

To get started with the app, make sure you have Rails and Git installed on your machine
Clone the repo to your local machine:

$ git clone git@github.com:BrentBarnes/Odin-Flight-Booker.git

Then, install the needed gems:

$ bundle install

Next, migrate the database:

$ rails db:migrate

Load sample airports and flights:

$ rails db:seed

Finally, on root path run a local server:

$ rails server

Open browser to view application:

localhost:3000

Run The Tests

Tests Include

Search Flights

  1. Valid inputs: Expect page to have content "From: San Francisco, CA | To: New York City, NY | Date: Monday, August 01"
  2. Invalid inputs: Expect page to have content "No flights found. Please make sure you have selected an option for each field."

Create Passengers

  1. Valid inputs: Expect page to have content "Your flight has successfully been booked. Welcome aboard!"
  2. Invalid inputs: Expect page to have content "You must fill out all fields"

After local installation, run:

$ bundle exec rspec spec/features/

Data Model Associations

class Airport < ApplicationRecord
  has_many :departing_flights, class_name: "Flight", foreign_key: :departure_airport_id
  has_many :arriving_flights, class_name: "Flight", foreign_key: :arrival_airport_id
end
class Flight < ApplicationRecord
  belongs_to :departure_airport, class_name: "Airport"
  belongs_to :arrival_airport, class_name: "Airport"
  has_many :bookings
  has_many :passengers
end
class Booking < ApplicationRecord
  belongs_to :flight
  has_many :passengers
  accepts_nested_attributes_for :passengers
end
class Passenger < ApplicationRecord
  belongs_to :booking
end

About

A Ruby-on-Rails app where users can book flights for multiple passengers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published