Added bike show api method

This commit is contained in:
Jason Denney
2014-03-08 15:03:52 -05:00
parent 523046b042
commit dc0a567a27
11 changed files with 111 additions and 10 deletions
+9 -1
View File
@@ -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
@@ -0,0 +1,3 @@
json.bikes [@bike] do |bike|
json.array! bike
end