Sha256: f21f244c35e508ef10fdadbcc15cc350ca35ea0cdb387a1a387dde44a8a1a21e

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # @see Archangel::BackendController
  #
  module Backend
    ##
    # Backend widgets controller
    #
    class WidgetsController < BackendController
      include Archangel::Controllers::ResourcefulConcern

      protected

      def permitted_resource_attributes
        %w[content design_id name slug]
      end

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

        authorize @widgets
      end

      def resource_content
        resource_id = params.fetch(:id)

        @widget = current_site.widgets.find_by!(slug: resource_id)

        authorize @widget
      end

      def resource_new_content
        @widget = current_site.widgets.new(resource_new_params)

        authorize @widget
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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