Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chopt make order ahead orders not reorderable
chopt_location_ids = [5652, 6397, 6646, 6647, 6648, 6650, 6651, 6652, 6653,
6654, 7169, 7170, 7453, 7454, 7624, 7625, 7626, 7627, 7628, 7629, 7630,
7631, 7632, 7633, 8015, 8482, 10153, 10619, 10620, 10823, 10824, 11457,
11560, 14504, 14505, 14820, 15323, 17342, 22070, 22074, 22100, 22101]
orders = Order.completed.where(location_id: chopt_location_ids,
reorderable: true)
# Iterate through all orders, mark as reorderable = false, print IDs
orders.find_each do |order|
order.update_column :reorderable, false
puts order.id
end
# Or: update all in one go, returns number of rows updated
orders.update_all reorderable: false #=> 181405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment