Sha256: 85794628d556e4d030f2bd835355c3c51491b76c6755c7bb1787d9caaa1cb234
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module Pwb class Api::V1::SectionsController < JSONAPI::ResourceController # Skipping action below allows me to browse to endpoint # without having set mime type skip_before_action :ensure_valid_accept_media_type # later version changes above method name # https://github.com/cerebris/jsonapi-resources/pull/806/files # https://github.com/cerebris/jsonapi-resources/pull/801 def index # can't figure out why default jsonapi index action returns nothing.. sections = Section.all # JSONAPI::ResourceSerializer.new(Api::V1::SectionResource).serialize_to_hash(Api::V1::SectionResource.new(sections, nil)) render json: sections end def bulk_update sectionsJSON = JSON.parse params[:items] sections = [] sectionsJSON.each do |sectionJSON| section = Section.find sectionJSON["id"] section.update(sectionJSON.slice("show_in_top_nav", "show_in_footer", "sort_order")) sections.push section end render json: sections.as_json end private def sections_params params.permit(:items, items: []) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pwb-1.2.0 | app/controllers/pwb/api/v1/sections_controller.rb |
pwb-1.1.1 | app/controllers/pwb/api/v1/sections_controller.rb |
pwb-1.0.0 | app/controllers/pwb/api/v1/sections_controller.rb |