Skip to content

Commit

Permalink
Remove v0 and specify serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
corincerami committed Jun 24, 2020
1 parent d19e17f commit 6237bbb
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 77 deletions.
26 changes: 0 additions & 26 deletions app/controllers/api/v0/photos_controller.rb

This file was deleted.

25 changes: 0 additions & 25 deletions app/controllers/api/v0/rovers_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/api/v1/latest_photos_controller.rb
Expand Up @@ -3,7 +3,7 @@ def index
def index
@rover = Rover.find_by name: params[:rover_id].titleize
if @rover
render json: search_photos
render json: search_photos, each_serializer: PhotoSerializer, root: :latest_photos
else
render json: { errors: "Invalid Rover Name" }, status: :bad_request
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/manifests_controller.rb
Expand Up @@ -3,7 +3,7 @@ def show
rover = Rover.find_by name: params[:id].capitalize
if rover.present?
manifest = rover.photo_manifest
render json: manifest
render json: manifest, serializer: PhotoManifestSerializer, root: :photo_manifest
else
render json: { errors: "Invalid Rover Name" }, status: :bad_request
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/photos_controller.rb
@@ -1,13 +1,13 @@
class Api::V1::PhotosController < ApplicationController
def show
photo = Photo.find params[:id]
render json: photo
render json: photo, serializer: PhotoSerializer, root: :photo
end

def index
rover = Rover.find_by name: params[:rover_id].titleize
if rover
render json: photos(rover)
render json: photos(rover), each_serializer: PhotoSerializer, root: :photos
else
render json: { errors: "Invalid Rover Name" }, status: :bad_request
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/rovers_controller.rb
@@ -1,7 +1,7 @@
class Api::V1::RoversController < ApplicationController
def index
rovers = Rover.all
render json: rovers
render json: rovers, each_serializer: RoverSerializer, root: :rovers
end

def show
Expand Down
5 changes: 0 additions & 5 deletions app/serializers/v0/photo_serializer.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/serializers/v0/rover_serializer.rb

This file was deleted.

5 changes: 0 additions & 5 deletions config/routes.rb
Expand Up @@ -12,10 +12,5 @@
resources :photos, only: :show
resources :manifests, only: :show
end

namespace :v0 do
resources :rovers, only: [:show, :index]
resources :photos, only: [:show, :index]
end
end
end

0 comments on commit 6237bbb

Please sign in to comment.