Just kidding, mate

About Saloflights

This app is an exercise from the OdinProject. I'll quote directly what they say:

Project: Flight Booker

In this project, you'll get a chance to tackle some more advanced forms. In this case, we'll build the first three steps of a typical checkout process for booking a one-way flight:

  1. Enter desired dates / airports and click "Search"
  2. Choose from among a list of eligible flights
  3. Enter passenger information for all passengers

Your Task

We'll be creating a one-way flight booker. You'll get lots of practice populating and building dropdown menus, radio buttons, and nested submissions.

This project will require you to seed your database, so use your db/seeds.rb file to write the code necessary to populate Airports and Flights.

It's also a good exercise on setting up associations, so you can ask Flight.first.from_airport, Flight.first.to_airport and get back Airport objects. Same for Airport.first.departing_flights and Airport.first.arriving_flights, which should return a list of Flight objects.

You will search and view results in the same page. Set up your FlightsController and routes.

The DATE dropdown should only include dates that have existing flights.

Keep the search form active at the top so the user can try running a new search.

Each returned flight should render with a radio button next to it. The user will select which flight to submit and move onto the next step. You'll need to include a hidden field that contains the number of passengers.

Set up associations between Bookings, Passengers, and Flights.

Set up your BookingsController#new action, which should have received the flight ID and passenger number parameters, and use it to help render a form for a new booking which displays the currently chosen date, airports, flight ID and a set of fields to enter personal information for each passenger. You'll want to create a new blank Passenger object in your controller for each passenger.

You'll need your #create action to create a new Booking (linking it to the appropriate Flight) but it will also need to accept the nested attributes for each of the Passenger objects and create a new Passenger from them.