app/models/order.rb
def order_create(product_id_array, count_array) #method for when order is created in the new order form
    self.items = []
    items_array = product_id_array.zip(count_array) #[[product id_1, product_count_1], [product_id_2, product_count_2]]
    items_array.each do |array|
      array[1].times do
        Item.create(product_id: array[0], order_id: self.id)
      end
    end
    self.save
  end
#methods related to create and update order from controller
methods related to create and update order from controller
methods related to create and update order from controller
def order_create(product_id_array, count_array) 
    self.items = []
    items_array = product_id_array.zip(count_array) 
    items_array.each do |array|
      array[1].times do
        Item.create(product_id: array[0], order_id: self.id)
      end
    end
    self.save
  end
def order_create ( product_id_array , count_array ) self . items = [ ] items_array = product_id_array . zip ( count_array ) items_array . each do | array | array [ 1 ] . times do Item . create ( product_id : array [ 0 ] , order_id : self . id ) end end self . save end
methods related to create and update order from controller
methods related to create and update order from controller
#method for when order is created in the new order form #[[product id_1, product_count_1], [product_id_2, product_count_2]]
product_id_array
count_array