Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrderStatus blank? #39

Open
hasandiwan opened this issue Jan 15, 2024 · 0 comments
Open

OrderStatus blank? #39

hasandiwan opened this issue Jan 15, 2024 · 0 comments

Comments

@hasandiwan
Copy link

How am I supposed to populate the OrderStatus table? I'm trying to process an order using stripe, but it is expecting the class to be populated:

def create
@order = OrderItem.where("product_id = ? AND order_id = ?", params[:order_item][:product_id], session[:order_id]).first
if @order
@order.update(quantity: @order.quantity + params[:order_item][:quantity].to_i)
@order.save
else
@order = current_order
@order.order_items.new(order_item_params) do
@order.order_status_id = 1
end
@order.save
session[:order_id] = @order.id
end

OrderItem is blank, I'm guessing, because this is the first order in the system. current_order is also blank, which seems strange. @order has an order_status_id of "1", which should map to OrderStatus(1), but there's nothing in OrderStatus yet, which is mind-boggling. Thanks in advance for any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant