DEV Community

loading...

Discussion on: Tips for Running Scripts in Production

Collapse
moopet profile image
Ben Sinclair

When I do this (which is more often than I'd admit in an interview) I'll usually do something like this:

# result = article.update(cached_tag_list: article.tags.pluck(:name).join(", "))
puts "result = article.update(cached_tag_list: #{article.tags.pluck(:name).join(", ")}"
continue

Excuse my butchered pseudo-ruby, I don't use it so am inferring from yours. What I mean, though, is I display what would be called as a kind of dry-run, and short-circuit the rest of the loop. Then when I'm ready, I uncomment the "real" line.

Collapse
molly profile image
Molly Struve (she/her) Author

That is definitely another great way to try it out first before actually doing it. When I "dry run" a script I usually run the script for a single object, check that it looks how I expect and then l let the script loose on the rest.