Class: Hyrax::Admin::CollectionTypeParticipantsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/hyrax/admin/collection_type_participants_controller.rb

Instance Method Summary collapse

Instance Method Details

#collection_type_participant_paramsObject



41
42
43
# File 'app/controllers/hyrax/admin/collection_type_participants_controller.rb', line 41

def collection_type_participant_params
  params.require(:collection_type_participant).permit(:access, :agent_id, :agent_type, :hyrax_collection_type_id)
end

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/hyrax/admin/collection_type_participants_controller.rb', line 11

def create
  @collection_type_participant = Hyrax::CollectionTypeParticipant.new(collection_type_participant_params)
  if @collection_type_participant.save
    redirect_to(
      edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
      notice: I18n.t('update_notice', scope: 'hyrax.admin.collection_types.form_participants')
    )
  else
    redirect_to(
      edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
      alert: @collection_type_participant.errors.full_messages.to_sentence
    )
  end
end

#destroyObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/hyrax/admin/collection_type_participants_controller.rb', line 26

def destroy
  @collection_type_participant = Hyrax::CollectionTypeParticipant.find(params[:id])
  if @collection_type_participant.destroy
    redirect_to(
      edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
      notice: I18n.t('remove_success', scope: 'hyrax.admin.collection_types.form_participants')
    )
  else
    redirect_to(
      edit_admin_collection_type_path(@collection_type_participant.hyrax_collection_type_id, anchor: 'participants'),
      alert: @collection_type_participant.errors.full_messages.to_sentence
    )
  end
end