Module: DataControllerConfiguration::ProjectDataControllerConfiguration

Extended by:
ActiveSupport::Concern
Included in:
AlternateValuesController, AssertedDistributionsController, BiocurationClassificationsController, BiologicalAssociationsController, BiologicalAssociationsGraphsController, BiologicalRelationshipsController, CharacterStatesController, CitationTopicsController, CitationsController, CollectingEventsController, CollectionObjectObservationsController, CollectionObjectsController, CollectionProfilesController, CombinationsController, CommonNamesController, ConfidenceLevelsController, ConfidencesController, ContainerItemsController, ContainersController, ContentsController, ControlledVocabularyTermsController, DataAttributesController, DepictionsController, DescriptorsController, DocumentationController, DocumentsController, ExtractsController, GeneAttributesController, Georeferences::GeoLocatesController, Georeferences::GoogleMapsController, GeoreferencesController, IdentifiersController, ImagesController, KeywordsController, LanguagesController, LoanItemsController, LoansController, NotesController, ObservationMatricesController, ObservationMatrixColumnItemsController, ObservationMatrixColumnsController, ObservationMatrixRowItemsController, ObservationMatrixRowsController, ObservationsController, OriginRelationshipsController, OtuPageLayoutSectionsController, OtuPageLayoutsController, OtusController, PredicatesController, ProjectSourcesController, ProtocolRelationshipsController, ProtocolsController, PublicContentsController, RangedLotCategoriesController, SequenceRelationshipsController, SequencesController, TaggedSectionKeywordsController, TagsController, TaxonDeterminationsController, TaxonNameClassificationsController, TaxonNameRelationshipsController, TaxonNamesController, TopicsController, TypeMaterialsController
Defined in:
app/controllers/concerns/data_controller_configuration/project_data_controller_configuration.rb

Instance Method Summary (collapse)

Instance Method Details

- (Hash) polymorphic_filter_params(object_name, permitted_model_ids = [])

Returns:

  • (Hash)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/concerns/data_controller_configuration/project_data_controller_configuration.rb', line 13

def polymorphic_filter_params(object_name, permitted_model_ids = [])
  h = params.permit(permitted_model_ids).to_h
  if h.size > 1 
    respond_to do |format|
      format.html { render plain: '404 Not Found', status: :unprocessable_entity and return }
      format.json { render json: {success: false}, status: :unprocessable_entity and return }
    end
  end

  model = h.keys.first.gsub(/_id$/, '').camelize
  return {"#{object_name}_type".to_sym => model,"#{object_name}_id".to_sym => h.values.first}
end