Sha256: 4ae3eee1f436974725bacfacb374b3f90f60be80849a95d69308bdcd49f5e195

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::Backend::ResourcefulConcern

      protected

      def permitted_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 unless @collection.fields.present?

        authorize @collection
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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