Class: Kuroko2::StarsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kuroko2/stars_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/kuroko2/stars_controller.rb', line 2

def create
  star = Kuroko2::Star.new do |star|
    star.job_definition = Kuroko2::JobDefinition.find(star_params[:job_definition_id])
    star.user           = current_user
  end

  if (star.save)
    render json: star, status: :created
  else
    raise HTTP::BadRequest
  end
end

#destroyObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/kuroko2/stars_controller.rb', line 15

def destroy
  star = Kuroko2::Star.find(params[:id])

  if (star.destroy)
    render json: star, status: :ok
  else
    raise HTTP::BadRequest
  end
end