End of evening commit, changing supplier to JSONAPI

This commit is contained in:
2015-09-08 23:22:13 +02:00
parent 3cb7fd2a6f
commit 9c1945252d
36 changed files with 195 additions and 230 deletions
@@ -2,13 +2,13 @@ module Suppliers
class SectionElementsController < Suppliers::ApplicationController
def index
@section_elements = SectionElement.for_supplier(current_supplier)
render json: @section_elements, each_serializer: Suppliers::SectionElementSerializer
render json: JSONAPI::Serializer.serialize(@section_elements, serializer: Suppliers::SectionElementSerializer, is_collection: true)
end
def create
@section_element.supplier = current_supplier
if @section_element.save
render json: @section_element, serializer: Suppliers::SectionElementSerializer
render json: JSONAPI::Serializer.serialize(@section_element, serializer: Suppliers::SectionElementSerializer)
else
render json: {errors: @section.errors}, status: :unprocessable_entity
end
@@ -16,7 +16,7 @@ module Suppliers
def update
if @section_element.update_attributes section_element_params
render json: @section_element, serializer: Suppliers::SectionElementSerializer
render json: JSONAPI::Serializer.serialize(@section_element, serializer: Suppliers::SectionElementSerializer)
else
render json: {errors: @section.errors}, status: :unprocessable_entity
end