app/controllers/granules_controller.rb
# Deletes the specified granule record (i.e., specific revision)using the
# specified "granule record id."
Deletes the specified granule record using the
specified "granule record id."
Deletes the specified granule record using the specified " granule record id . "
def destroy
    granule = Granule.find(params[:id])
    granule_record = Record.find(params[:record_id])
    collection = granule.collection
    authorize! :delete_granule, granule
    begin
      granule_record.destroy
      if granule.records == 0
        granule.destroy
      end
      flash[:notice] = "Granule has been deleted."
      redirect_to collection_path(id: 1, record_id: collection.records.first.id)
    rescue ActiveRecord::ActiveRecordError => e
      flash[:notice] = 'Sorry, Error occurred deleting granule review.'
      Rails.logger.error("Sorry, Error occurred deleting granule review.  error=#{e.message}")
      redirect_to collection_path(id: 1, record_id: collection.records.first.id)
    rescue Cmr::CmrError => e
      flash[:notice] = 'Sorry, Error occurred retrieving granule metadata from CMR.'
      Rails.logger.error("Sorry, Error occurred retrieving granule metadata from CMR.  error=#{e.message}")
      redirect_to collection_path(id: 1, record_id: collection.records.first.id)
    end
  end
def destroy granule = Granule . find ( params [ :id ] ) granule_record = Record . find ( params [ :record_id ] ) collection = granule . collection authorize! :delete_granule , granule begin granule_record . destroy if granule . records == 0 granule . destroy end flash [ :notice ] = "Granule has been deleted." redirect_to collection_path ( id : 1 , record_id : collection . records . first . id ) rescue ActiveRecord :: ActiveRecordError => e flash [ :notice ] = 'Sorry, Error occurred deleting granule review.' Rails . logger . error ( "Sorry, Error occurred deleting granule review.  error=#{e.message}" ) redirect_to collection_path ( id : 1 , record_id : collection . records . first . id ) rescue Cmr :: CmrError => e flash [ :notice ] = 'Sorry, Error occurred retrieving granule metadata from CMR.' Rails . logger . error ( "Sorry, Error occurred retrieving granule metadata from CMR.  error=#{e.message}" ) redirect_to collection_path ( id : 1 , record_id : collection . records . first . id ) end end
Deletes the specified granule record (i.e., specific revision)using the
specified "granule record id."
Deletes the specified granule record ( i . e . specific revision ) using the specified " granule record id . "