I’m trying to make a long running script (it runs for about 2 hours) display its progress and the coded in HTML updates as it runs rather than waiting until the script completes to show the entire result.
Having searched for answers, and Stack Overflow, I’ve found an answer, which is to use
render stream: true in the controller. However, it doesn’t work with my view for some reason.
def import @shelfunit = @discogs.get_user_folders(@user.username) # above is API connector for Discogs-Wrapper Gem render stream: true end
<h1>Title</h1> <% # set some variables # write to database %> <h2>Status Update</h2> <% # For each do # set some variables # write to database %> <h2>Status Update</h2> <% # End For each %>
It’s currently waiting until the script has finished to display anything at all, I’m getting no errors, but I want it to stream the view, and all the HTML as it reaches it rather than waiting.
Can anyone please advise where I’m going wrong?