You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
642 B
30 lines
642 B
5 years ago
|
class ItemBasketsController < ApplicationController
|
||
|
before_action :require_login
|
||
|
|
||
|
def index
|
||
|
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
ItemBaskets::SaveItemBasketService.call(current_user, create_params)
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
item = current_user.item_baskets.find_by!(item_bank_id: params[:id])
|
||
|
ActiveRecord::Base.transaction do
|
||
|
current_user.item_baskets.where("item_type = #{item.item_type} and position > #{item.position}").update_all("position = position -1")
|
||
|
item.destroy!
|
||
|
end
|
||
|
render_ok
|
||
|
end
|
||
|
|
||
|
def delete_item_type
|
||
|
# tip_exception() unless
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def create_params
|
||
|
params.permit(item_ids: [])
|
||
|
end
|
||
|
end
|