Sha256: e6e97da416941128f240b7027a6ec6c992d78aff42c13b3f0b4ccd4ddb7baf50

Contents?: true

Size: 612 Bytes

Versions: 5

Compression:

Stored size: 612 Bytes

Contents

module ElocalApiSupport
  module Actions
    module Destroy
      def destroy
        # record not found is ok for destroy
        render json: { errors: "Cannot retrieve record: #{params[:id]}" } and return \
          if lookup_object.nil?

        if lookup_object.destroy
          render json: lookup_object
        else
          render json: { errors: "Failed to destroy #{lookup_object}" }, status: 500
        end
      rescue ActiveRecord::RecordNotFound
        # record not found is ok for destroy
        render json: { errors: "Cannot retrieve record: #{params[:id]}" }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
elocal_api_support-1.3.0 lib/elocal_api_support/actions/destroy.rb
elocal_api_support-1.2.0 lib/elocal_api_support/actions/destroy.rb
elocal_api_support-1.1.0 lib/elocal_api_support/actions/destroy.rb
elocal_api_support-1.0.0 lib/elocal_api_support/actions/destroy.rb
elocal_api_support-0.1.10 lib/elocal_api_support/actions/destroy.rb