Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create
- @product = Product.find_by(id: params[:product_id])
- @order = @product.transactions.new(order_params)
- @order.user_id = current_user.id
- @order.mode = "ORDER"
- @order.quantity = @order.quantity * -1
- if @product.save
- redirect_to product_path(@product), notice: "Order has been added."
- else
- render 'new'
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement