This tip comes by way of: @starvo.

By using a counter in your ruby console script you can gain insight into long running actions for your application.

@photos = Photo.all
count = @photos.count
@photos.each_with_index do |photo, idx|
  # ... do a bunch of processing
  puts "#{(100.0 * idx / count).round(2)}%"
end
 
# When the script is run we will get a percentage complete counter like:
#=> 0.1%
#=> 0.2%
#=> 0.3%
#=> 0.4%
#=> ...

:)

Leave a Reply

Your email address will not be published. Required fields are marked *