class TbCommerce::Api::CartItemsController < TbCommerce::Api::BaseController before_action :load_cart before_action :load_cart_item, :only => [:update, :destroy] def create @cart_item = @cart.cart_items.create(cart_item_params) respond_with @cart_item end def update @cart_item.update_attributes(cart_item_params) respond_with @cart_item end def destroy @cart_item.destroy() respond_with @cart_item end private def load_cart @cart = tb_commerce_current_cart end def load_cart_item @cart_item = @cart.cart_items.find_by!(:id => params[:id]) end def cart_item_params params.require(:tb_commerce_cart_item).permit(:tb_commerce_product_sku_id, :quantity).tap do |white_listed| white_listed[:configuration] = params[:tb_commerce_cart_item][:configuration] if params[:tb_commerce_cart_item][:configuration].present? end end end