I am working on a rather lengthy seed.rb
file.
Since it takes the rake task a while to complete, I want to give visual feedback through the console to the user so they know the process is working.
So far, I have:
puts "Topic: #{i}, created..."
inside the create loop. However, it spams the terminal output. What I would like to do is have the output look like this:
Topic: #1..N, created...
where the output all stays on the same line, without creating a /n
newline character, like what the current output looks like:
Topic: #1, created...
Topic: #2, created...
Topic: #3, created...
Topic: #N, created...
I have tried fiddling with print
instead, but it just creates a long string wrapping at the end of the terminal line.
Any ideas?
EDIT This is the entire seed.rb
code:
topic_list = []
i = 1
(0..9).map{
topic_list << [ Faker::Lorem.words(rand(2..5)), Faker::Lorem.sentences(rand(3..7)), rand(1..6) ]
}
topic_list.each do |title, content, author|
Topic.create!( title:title, content:content, author:author )
puts "Topic: #{i}, #{title} created..."
i += 1
end
Aucun commentaire:
Enregistrer un commentaire