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


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

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


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

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