Base progress
This commit is contained in:
@@ -8,13 +8,13 @@ module Suppliers
|
||||
# GET /employees.json
|
||||
def index
|
||||
@employees = current_supplier.employees
|
||||
render json: JSONAPI::Serializer.serialize(@employees, serializer: Suppliers::EmployeeSerializer, is_collection: true)
|
||||
render json: @employees
|
||||
end
|
||||
|
||||
# GET /employees/1
|
||||
# GET /employees/1.json
|
||||
def show
|
||||
render json: JSONAPI::Serializer.serialize(@employee, serializer: Suppliers::EmployeeSerializer)
|
||||
render json: @employee
|
||||
end
|
||||
|
||||
# POST /employees
|
||||
@@ -37,7 +37,7 @@ module Suppliers
|
||||
end
|
||||
|
||||
if valid
|
||||
render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
|
||||
render json: @employee
|
||||
else
|
||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||
end
|
||||
@@ -47,12 +47,10 @@ module Suppliers
|
||||
# PUT /employees/1.json
|
||||
def update
|
||||
#current_supplier.settings_for(@employee).update!(employee_params)
|
||||
respond_to do |format|
|
||||
if @employee.update_attributes(employee_params)
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.json { render json: {errors: @employee.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
if @employee.update_attributes(employee_params)
|
||||
render json: @employee
|
||||
else
|
||||
render json: {errors: @employee.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,10 +59,7 @@ module Suppliers
|
||||
def destroy
|
||||
head :forbidden and return if @employee == current_employee # do not remove self at the moment
|
||||
current_supplier.remove_employee @employee
|
||||
|
||||
respond_to do |format|
|
||||
format.json { head :no_content }
|
||||
end
|
||||
head :no_content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user