Added device jobs model
This commit is contained in:
51
app/controllers/device_jobs_controller.rb
Normal file
51
app/controllers/device_jobs_controller.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
class DeviceJobsController < ApplicationController
|
||||
before_action :set_device_job, only: [:show, :update, :destroy]
|
||||
|
||||
# GET /device_jobs
|
||||
def index
|
||||
@device_jobs = DeviceJob.all
|
||||
|
||||
render json: @device_jobs
|
||||
end
|
||||
|
||||
# GET /device_jobs/1
|
||||
def show
|
||||
render json: @device_job
|
||||
end
|
||||
|
||||
# POST /device_jobs
|
||||
def create
|
||||
@device_job = DeviceJob.new(device_job_params)
|
||||
|
||||
if @device_job.save
|
||||
render json: @device_job, status: :created, location: @device_job
|
||||
else
|
||||
render json: @device_job.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /device_jobs/1
|
||||
def update
|
||||
if @device_job.update(device_job_params)
|
||||
render json: @device_job
|
||||
else
|
||||
render json: @device_job.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /device_jobs/1
|
||||
def destroy
|
||||
@device_job.destroy
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_device_job
|
||||
@device_job = DeviceJob.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def device_job_params
|
||||
params.require(:device_job).permit(:references, :references, :id, :job_id, :device_id)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user