Class: Hyrax::FeaturedWorksController

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

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/hyrax/featured_works_controller.rb', line 4

def create
  authorize! :create, FeaturedWork
  @featured_work = FeaturedWork.new(work_id: params[:id])

  respond_to do |format|
    if @featured_work.save
      format.json { render json: @featured_work, status: :created }
    else
      format.json { render json: @featured_work.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/hyrax/featured_works_controller.rb', line 17

def destroy
  authorize! :destroy, FeaturedWork
  @featured_work = FeaturedWork.find_by(work_id: params[:id])
  @featured_work&.destroy

  respond_to do |format|
    format.json { head :no_content }
  end
end