Files
openfoodnetwork/app/controllers/api/customers_controller.rb
Rob Harrington ffa8a8c7d6 Create Api::BaseController to allow use of ActiveModelSerializers
Also add index action to Api::CustomersController
2018-06-22 15:39:47 +10:00

20 lines
497 B
Ruby

module Api
class CustomersController < BaseController
def index
@customers = current_api_user.customers
render json: @customers, each_serializer: CustomerSerializer
end
def update
@customer = Customer.find(params[:id])
authorize! :update, @customer
if @customer.update_attributes(params[:customer])
render json: @customer, serializer: CustomerSerializer, status: 200
else
invalid_resource!(@customer)
end
end
end
end