app/controllers/granules_controller.rb
# Pulls a new random granule and associates with the specified "collection id".
Pulls a new random granule and associates with the specified "collection id".
Pulls a new random granule and associates with the specified " collection id " .
def create
    collection = Collection.find(params[:id])
    authorize! :create_granule, collection
    begin
      granule = collection.add_granule_with_concept_id(current_user, collection.concept_id)
      flash[:notice] = granule.nil? ? "No Granules Available!" : "A new random granule has been added for this collection"
      redirect_to collection_path(id: 1, record_id: collection.records.first.id)
    rescue ActiveRecord::ActiveRecordError => e
      flash[:notice] = 'Sorry, Error occurred creating granule review.'
      Rails.logger.error("Sorry, Error occurred creating 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 create collection = Collection . find ( params [ :id ] ) authorize! :create_granule , collection begin granule = collection . add_granule_with_concept_id ( current_user , collection . concept_id ) flash [ :notice ] = granule . nil? ? "No Granules Available!" : "A new random granule has been added for this collection" redirect_to collection_path ( id : 1 , record_id : collection . records . first . id ) rescue ActiveRecord :: ActiveRecordError => e flash [ :notice ] = 'Sorry, Error occurred creating granule review.' Rails . logger . error ( "Sorry, Error occurred creating 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
Pulls a new random granule and associates with the specified "collection id".
Pulls a new random granule and associates with the specified " collection id " .