Class: SupplejackApi::SetItemsController

Inherits:
ApplicationController show all
Includes:
Concerns::SetItemsControllerMetrics
Defined in:
app/controllers/supplejack_api/set_items_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin!, #authenticate_user!, #current_user, #find_user_set

Instance Method Details

#createObject



17
18
19
20
21
# File 'app/controllers/supplejack_api/set_items_controller.rb', line 17

def create
  @set_item = @user_set.set_items.build(record_params)
  @user_set.save
  respond_with @user_set, @set_item
end

#destroyObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/supplejack_api/set_items_controller.rb', line 23

def destroy
  @set_item = @user_set.set_items.find_by_record_id(params[:id])
  if @set_item
    @set_item.destroy
    @user_set.save
    respond_with @user_set, @set_item
  else
    render json: { errors: "The record with id: #{params[:id]} was not found." }, status: :not_found
  end
end

#record_paramsObject



34
35
36
# File 'app/controllers/supplejack_api/set_items_controller.rb', line 34

def record_params
  params.require(:record).permit(:record_id)
end