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
- 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)
Loading/Search Page Search Results Passenger Information Final Booking Mailer
When booking two passengers, it will send confirmation emails to each passenger. Tests
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
Tests Include
Search Flights
- Valid inputs: Expect page to have content "From: San Francisco, CA | To: New York City, NY | Date: Monday, August 01"
- Invalid inputs: Expect page to have content "No flights found. Please make sure you have selected an option for each field."
Create Passengers
- Valid inputs: Expect page to have content "Your flight has successfully been booked. Welcome aboard!"
- Invalid inputs: Expect page to have content "You must fill out all fields"
After local installation, run:
$ bundle exec rspec spec/features/
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