Add & Display Flights
This commit is contained in:
29
app/controllers/flights_controller.rb
Normal file
29
app/controllers/flights_controller.rb
Normal 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
|
||||
Reference in New Issue
Block a user