diff --git a/app/controllers/api/v1/aeroplanes_controller.rb b/app/controllers/api/v1/aeroplanes_controller.rb new file mode 100644 index 0000000..a0d706b --- /dev/null +++ b/app/controllers/api/v1/aeroplanes_controller.rb @@ -0,0 +1,8 @@ +class Api::V1::AeroplanesController < ApplicationController + # GET /aeroplanes + def index + @aeroplanes = Aeroplane.all + + render json: { aeroplanes: @aeroplanes } + end +end diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 0e3a648..4ffa29a 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -1,6 +1,6 @@ class UserSerializer include JSONAPI::Serializer - attributes :id, :email, :created_at, :name + attributes :id, :email, :created_at, :name, :role attribute :created_date do |user| user.created_at&.strftime('%m/%d/%Y') diff --git a/db/seeds.rb b/db/seeds.rb index 4fbd6ed..2c865bb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,3 +7,10 @@ # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| # MovieGenre.find_or_create_by!(name: genre_name) # end +# Create a dummy User +User.create(name: 'John') + +# Create some sample aeroplanes +Aeroplane.create(name: 'Aeroplane 1', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true) +Aeroplane.create(name: 'Aeroplane 2', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true) +Aeroplane.create(name: 'Aeroplane 3', model: 'https://images.unsplash.com/photo-1464037866556-6812c9d1c72e?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', image: 'image1', description: 'yolo', number_of_seats: 100, location: 'test', fee: 90.0, reserved: true)