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:
- Enter desired dates / airports and click "Search"
- Choose from among a list of eligible flights
- Enter passenger information for all passengers
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.rbfile 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.to_airportand get back
Airportobjects. Same for
Airport.first.arriving_flights, which should return a list of
You will search and view results in the same page. Set up your
DATEdropdown 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#newaction, 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
#createaction 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.