app/models/shipment.rb
def update_order
    statuses = Shipment.where(order_id: order_id).distinct(:status).pluck(:status)

    if statuses == ["shipped"] || statuses == ["cancelled"]
      Order.where(id: order_id).update_all(status: statuses[0])
    elsif statuses.include?("shipped")
      Order.where(id: order_id).update_all(status: "partially_shipped")
    end
  end
# this callback is executed after shipment is saved
this callback is executed after shipment is saved
this callback is executed after shipment is saved
def update_order
    statuses = Shipment.where(order_id: order_id).distinct(:status).pluck(:status)
    if statuses == ["shipped"] || statuses == ["cancelled"]
      Order.where(id: order_id).update_all(status: statuses[0])
    elsif statuses.include?("shipped")
      Order.where(id: order_id).update_all(status: "partially_shipped")
    end
  end
def update_order statuses = Shipment . where ( order_id : order_id ) . distinct ( :status ) . pluck ( :status ) if statuses == [ "shipped" ] || statuses == [ "cancelled" ] Order . where ( id : order_id ) . update_all ( status : statuses [ 0 ] ) elsif statuses . include? ( "shipped" ) Order . where ( id : order_id ) . update_all ( status : "partially_shipped" ) end end
this callback is executed after shipment is saved
this callback is executed after shipment is saved