Files
flights/app/controllers/flights_controller.rb
2022-01-15 16:05:31 -05:00

30 lines
475 B
Ruby

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