class FlightsController < ApplicationController # Display past flights def index @flights = Flight.all end # Display single flight def show @flight = Flight.find(params[:id]) end def new @flight = Flight.new @aircraft = Aircraft.all @flight.date = Date.current end def create @flight = Flight.new(params) if @flight.save redirect_to @flight else render :new, status: :unprocessable_entity end end end