1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/controllers/concerns/api/order_concern.rb

23 lines
483 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Concern for CartController and CheckoutController
module API::OrderConcern
private
def order_token
request.headers['X-Fablab-Order-Token'] || cart_params[:order_token]
end
def current_order
@current_order = Order.find_by(token: order_token)
end
def ensure_order
raise ActiveRecord::RecordNotFound if @current_order.nil?
end
2022-08-25 08:52:17 +02:00
def cart_params
params.permit(:order_token, :orderable_id, :quantity, :user_id)
end
end