Add & Display Flights

This commit is contained in:
2022-01-15 16:05:31 -05:00
parent 796a070af4
commit 022b63fc1a
26 changed files with 395 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
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