Sha256: d766d8402c677096b5f346e5c82aaf009989ec394202dcf7d43268f981dfe005

Contents?: true

Size: 638 Bytes

Versions: 40

Compression:

Stored size: 638 Bytes

Contents

module Rao
  module Api
    module ResourcesController::DestroyAllActionConcern
      extend ActiveSupport::Concern

      included do
        if respond_to?(:before_action)
          before_action :load_and_destroy_collection, only: [:destroy_all]
        else
          before_filter :load_and_destroy_collection, only: [:destroy_all]
        end
      end

      def destroy_all
        respond_to do |format|
          format.json { render json: serialize_collection(@collection) }
        end
      end

      private

      def load_and_destroy_collection
        @collection = resource_class.destroy_all
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
rao-api-resources_controller-0.0.52.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.51.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.50.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.49.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.48.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.47.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.46.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.45.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.44.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.43.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.42.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.41.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.40.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.39.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.38.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.37.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.36.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.35.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.34.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb
rao-api-resources_controller-0.0.33.pre app/concerns/rao/api/resources_controller/destroy_all_action_concern.rb