mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Added bike show api method
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
class Api::V1::BikesController < Api::V1::BaseController
|
||||
CANNOT_MANAGE = "You do not have permission to manage bikes."
|
||||
EXPECTED_BIKE = "Expected bike in submitted data"
|
||||
NOT_FOUND = "The bike could not be found."
|
||||
|
||||
before_filter :check_bike_permission
|
||||
before_filter :check_bike_permission, except: :show
|
||||
|
||||
def create
|
||||
if params[:bikes] && bike = params[:bikes].first
|
||||
@@ -15,6 +16,13 @@ class Api::V1::BikesController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@bike = Bike.find_by_id(params[:id])
|
||||
if @bike.nil?
|
||||
render json: { errors: [NOT_FOUND] }, status: 404 and return
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_bike_permission
|
||||
if cannot? :manage, Bike
|
||||
|
||||
Reference in New Issue
Block a user