Sha256: e17ef6488567bb495d747d08c8d7f20b9e22745f1b70fdc73a6df567ae590ca5

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Archangel
  ##
  # @see Archangel::BackendController
  #
  module Backend
    ##
    # Backend collections controller
    #
    class CollectionsController < BackendController
      include Archangel::Controllers::ResourcefulConcern

      protected

      def permitted_resource_attributes
        [
          :name, :slug,
          fields_attributes: %i[id _destroy classification label required slug]
        ]
      end

      def resources_content
        @collections = current_site.collections
                                   .order(name: :asc)
                                   .page(page_num).per(per_page)

        authorize @collections
      end

      def resource_content
        resource_id = params.fetch(:id)

        @collection = current_site.collections.find_by!(slug: resource_id)

        authorize @collection
      end

      def resource_new_content
        @collection = current_site.collections.new(resource_new_params)

        @collection.fields.build if @collection.fields.blank?

        authorize @collection
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 app/controllers/archangel/backend/collections_controller.rb